private void mnuNewFromExisting_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild is StoreManagerForm) { IStorageProvider manager = ((StoreManagerForm)this.ActiveMdiChild).Manager; IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(manager.GetType()); if (def != null) { if (manager is IConfigurationSerializable) { Graph g = new Graph(); ConfigurationSerializationContext ctx = new ConfigurationSerializationContext(g); INode n = g.CreateBlankNode(); ctx.NextSubject = n; ((IConfigurationSerializable)manager).SerializeConfiguration(ctx); def.PopulateFrom(g, n); EditConnectionForm editConn = new EditConnectionForm(def); if (editConn.ShowDialog() == DialogResult.OK) { StoreManagerForm managerForm = new StoreManagerForm(editConn.Connection); this.AddRecentConnection(editConn.Connection); managerForm.MdiParent = this; managerForm.Show(); } return; } } } } MessageBox.Show("The current connection is not editable", "New Connection from Current Error", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void mnuOpenConnection_Click(object sender, EventArgs e) { this.ofdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false); if (this.ofdConnection.ShowDialog() == DialogResult.OK) { try { Graph g = new Graph(); FileLoader.Load(g, this.ofdConnection.FileName); OpenConnectionForm openConnections = new OpenConnectionForm(g); openConnections.MdiParent = this; if (openConnections.ShowDialog() == DialogResult.OK) { IStorageProvider manager = openConnections.Connection; StoreManagerForm genManagerForm = new StoreManagerForm(manager); genManagerForm.MdiParent = this; genManagerForm.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } } catch (RdfParseException) { MessageBox.Show("Unable to open a connection from the given file as it was not a valid RDF Graph or was in a format that the library does not understand", "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Unable to open the given file due to the following error:\n" + ex.Message, "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void FillConnectionList(IGraph config, ListBox lbox) { SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS)); query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace)); query.CommandText = "SELECT * WHERE { ?obj a " + ConfigurationLoader.ClassGenericManager + " . OPTIONAL { ?obj rdfs:label ?label } }"; query.CommandText += " ORDER BY DESC(?obj)"; SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet; if (results != null) { foreach (SparqlResult r in results) { QuickConnect connect; if (r.HasValue("label") && r["label"] != null) { connect = new QuickConnect(config, r["obj"], r["label"].ToString()); } else { connect = new QuickConnect(config, r["obj"]); } lbox.Items.Add(connect); } } lbox.DoubleClick += new EventHandler((sender, args) => { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect != null) { try { IGenericIOManager manager = connect.GetConnection(); StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } catch (Exception ex) { MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); }
private void FillConnectionList(IGraph config, ListBox lbox) { SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS)); query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace)); query.CommandText = "SELECT * WHERE { ?obj a " + ConfigurationLoader.ClassGenericManager + " . OPTIONAL { ?obj rdfs:label ?label } }"; query.CommandText += " ORDER BY DESC(?obj)"; SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet; if (results != null) { foreach (SparqlResult r in results) { QuickConnect connect; if (r.HasValue("label") && r["label"] != null) { connect = new QuickConnect(config, r["obj"], r["label"].ToString()); } else { connect = new QuickConnect(config, r["obj"]); } lbox.Items.Add(connect); } } lbox.DoubleClick += new EventHandler((sender, args) => { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect != null) { try { IGenericIOManager manager = connect.GetConnection(); StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } catch (Exception ex) { MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); }
private void mnuNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); newConn.StartPosition = FormStartPosition.CenterParent; if (newConn.ShowDialog() == DialogResult.OK) { IStorageProvider manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = this; storeManager.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } }
private void btnNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); if (newConn.ShowDialog() == DialogResult.OK) { IStorageProvider manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } }
private void EditConnection(ListBox lbox) { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect == null) { return; } Type t = connect.Type; if (t != null) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(t); if (def != null) { def.PopulateFrom(connect.Graph, connect.ObjectNode); EditConnectionForm edit = new EditConnectionForm(def); if (edit.ShowDialog() == DialogResult.OK) { IStorageProvider manager = edit.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("The selected connection is not editable", "Edit Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("The selected connection is not editable", "Edit Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void QuickConnectClick(object sender, EventArgs e) { if (sender == null) { return; } Object tag = null; if (sender is Control) { tag = ((Control)sender).Tag; } else if (sender is ToolStripItem) { tag = ((ToolStripItem)sender).Tag; } else if (sender is Menu) { tag = ((Menu)sender).Tag; } if (tag != null) { if (tag is QuickConnect) { QuickConnect qc = (QuickConnect)tag; try { IStorageProvider manager = qc.GetConnection(); StoreManagerForm genManager = new StoreManagerForm(manager); genManager.MdiParent = this; genManager.Show(); } catch (Exception ex) { MessageBox.Show("Unable to load the Connection due to an error: " + ex.Message, "Quick Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void FillConnectionList(IGraph config, ListBox lbox) { SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS)); query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace)); query.CommandText = "SELECT * WHERE { ?obj a @type . OPTIONAL { ?obj rdfs:label ?label } }"; query.CommandText += " ORDER BY DESC(?obj)"; query.SetParameter("type", config.CreateUriNode(UriFactory.Create(ConfigurationLoader.ClassStorageProvider))); SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet; if (results != null) { foreach (SparqlResult r in results) { QuickConnect connect; if (r.HasValue("label") && r["label"] != null) { connect = new QuickConnect(config, r["obj"], r["label"].ToString()); } else { connect = new QuickConnect(config, r["obj"]); } lbox.Items.Add(connect); } } lbox.DoubleClick += new EventHandler((sender, args) => { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect != null) { if (Properties.Settings.Default.AlwaysEdit) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(connect.Type); if (def != null) { def.PopulateFrom(connect.Graph, connect.ObjectNode); EditConnectionForm edit = new EditConnectionForm(def); if (edit.ShowDialog() == DialogResult.OK) { IStorageProvider manager = edit.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("Selected Connection is not editable", "Connection Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { try { IStorageProvider manager = connect.GetConnection(); StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); try { //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); } catch { // silently ignore this error? seems like if MaxRecentConnections is hit, there is a bug in removing old connections... } this.Close(); } catch (Exception ex) { MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }); }
private void btnNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); if (newConn.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } }
private void QuickEditClick(object sender, EventArgs e) { if (sender == null) { return; } Object tag = null; if (sender is Control) { tag = ((Control)sender).Tag; } else if (sender is ToolStripItem) { tag = ((ToolStripItem)sender).Tag; } else if (sender is Menu) { tag = ((Menu)sender).Tag; } if (tag != null) { if (tag is QuickConnect) { QuickConnect qc = (QuickConnect)tag; try { if (qc.Type != null) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(qc.Type); if (def != null) { def.PopulateFrom(qc.Graph, qc.ObjectNode); EditConnectionForm editConn = new EditConnectionForm(def); if (editConn.ShowDialog() == DialogResult.OK) { IStorageProvider manager = editConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections this.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("This Connection is not ediatable", "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("This Connection is not ediatable", "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Unable to edit the Connection due to an error: " + ex.Message, "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void mnuNewConnection_Click(object sender, EventArgs e) { NewConnectionForm newConn = new NewConnectionForm(); newConn.StartPosition = FormStartPosition.CenterParent; if (newConn.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = newConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = this; storeManager.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } }
private void QuickConnectClick(object sender, EventArgs e) { if (sender == null) return; Object tag = null; if (sender is Control) { tag = ((Control)sender).Tag; } else if (sender is ToolStripItem) { tag = ((ToolStripItem)sender).Tag; } else if (sender is Menu) { tag = ((Menu)sender).Tag; } if (tag != null) { if (tag is QuickConnect) { QuickConnect qc = (QuickConnect)tag; try { IGenericIOManager manager = qc.GetConnection(); StoreManagerForm genManager = new StoreManagerForm(manager); genManager.MdiParent = this; genManager.Show(); } catch (Exception ex) { MessageBox.Show("Unable to load the Connection due to an error: " + ex.Message, "Quick Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void mnuOpenConnection_Click(object sender, EventArgs e) { this.ofdConnection.Filter = MimeTypesHelper.GetFilenameFilter(true, false, false, false, false, false); if (this.ofdConnection.ShowDialog() == DialogResult.OK) { try { Graph g = new Graph(); FileLoader.Load(g, this.ofdConnection.FileName); OpenConnectionForm openConnections = new OpenConnectionForm(g); openConnections.MdiParent = this; if (openConnections.ShowDialog() == DialogResult.OK) { IGenericIOManager manager = openConnections.Connection; StoreManagerForm genManagerForm = new StoreManagerForm(manager); genManagerForm.MdiParent = this; genManagerForm.Show(); //Add to Recent Connections this.AddRecentConnection(manager); } } catch (RdfParseException) { MessageBox.Show("Unable to open a connection from the given file as it was not a valid RDF Graph or was in a format that the library does not understand", "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Unable to open the given file due to the following error:\n" + ex.Message, "Open Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }