We bring Canada's leading lenders to you.
Run some numbers through our amortization calculator.
View all of the latest rates.
Complete a mortgage application online. Apply now!
Check out the low rates our customers have gotten over the past week!
A mortage can be a big commitment, but getting one doesn't have to be a frightening ordeal. This page will help explain what mortages are, and how we can help you get the best deal. If you still have questions, our Mortgage Specialists are always available to help you. Call us at (204) 982-1961.
Most people do not pay the entire cost of a home with cash up front – people arrange for a "mortgage" instead. A mortgage is a loan for which you put up the property you are buying as collateral (technically, a mortgage is the document you take to the Land Titles Office as proof of the loan, but we'll use it with its broader meaning).
Mortgages are amortized loans. Most mortgages have an amortization (the time it takes to pay off the loan and interest) of 25 years, though some can be amortized in as few as 5 years or in as many as 40 years. Over a long period of time, even a small difference in interest rate can make a huge difference in the end. That's why you want to find the lowest rate possible – saving even just a fraction of a percentage point can help.
Separate from amortization is the term of the loan. That's how long the interest rate is guaranteed. At the end of the term, you need to negotiate a new mortgage for the outstanding part of the loan. Generally, shorter terms offer lower rates, but you run the risk of having to renegotiate at a time when interest rates could be on the climb. Conversely, longer terms may carry slightly higher interest rates, but they can give you peace of mind if rates go up.
In addition to the interest rate, there are other features to look for when getting a mortgage. For example, will you be allowed to skip a payment if you need the money for something else? What about penalties for prepayment (paying off a mortgage before its amortization)? Will your mortgage be portable (can you transfer it to a new property)? Consider the features that each lender offers.
Generally, you will have to make a down payment on any property for which you want to get a mortgage. With less than 20% down payment, you'll need mortgage insurance. However, you can now buy a home with as little as 0% down. Go to the CMHC or Genworth Websites for more information.
We are here to help you get the best deal on your mortgage. Of course, our Mortgage Specialists are always available to help you. Call us at (204) 982-1961.
The Mortgage Centre Canada is a member of the CIBC group of companies. Independently owned and operated franchise offices are found across Canada. The Mortgage Centre has been helping people get the best deal on their mortgages for the past 20 years. The Mortgage Centre gets Canada's leading lenders to compete for your mortgage in an electronic bid process that, when combined with advice from your Mortgage Centre Specialist, guarantees you the best available package of rate and features. We require only one credit check and – best of all – our service is free! Visit the national Mortgage Centre Canada Website for more information.
Total Mortgage & Credit Services was established May 1985. Franchise owner Brad Wladyka, has over 35 years of experience in the mortgage industry. Widely known and well respected in the industry, Brad has made it his mission to help fulfill his customers' needs by finding the best deals for them.
General links relating to policy and terminology.


Since the release of Rather You Than Me in March, Rick Ross has kept busy with a series of guest appearances, videos and remixes.
In the last two months, he's dropped videos for "Santorini Greece" and "Lamborghini Doors" with Meek Mill. He's joined Lloyd on "Heavenly Body," Action Bronson on "9-24-7000," and Sammie (yes, that Sammie) on "Good Life." He also appeared A$AP Ferg's "East Coast (Remix)" with Busta Rhymes, Dave East, A$AP Rocky and a few others.
Now, with Miami's Bruno Mali riding shotgun, the Bawse digs in the crates and puts his spin on Total's '90s classic, "Can't You See" with The Notorious B.I.G.


text:
Town subs tame the Lions
Derek Davis
Published: 8:15 AM January 2, 2003
AN inspired double substitution led to victory over Millwall, which catapulted Ipswich Town into the top half of Division One.With the game at a stalemate Blues boss Joe Royle threw on Marcus Bent and Darren Ambrose eight minutes after the half time break and got immediate results.
By Derek Davis
AN inspired double substitution led to victory over Millwall, which catapulted Ipswich Town into the top half of Division One.
With the game at a stalemate Blues boss Joe Royle threw on Marcus Bent and Darren Ambrose eight minutes after the half time break and got immediate results.
Bent scored one and helped set up Jermaine Wright to hit a thunderous 30-yard goal against his first club. Ambrose supplied the corner which led to Tommy Miller's first goal and won the penalty for his second and Town's fourth.
Millwall took advantage of the changed formation in Ipswich's defence to level after Miller had given Town the lead. Steven Reid driving in from 14 yards after Neil Harris set him up.
Jim Magilton twice hit the woodwork as the Blues created a multitude of chances and Pablo Counago for once failed to take advantage of so many opportunities at Portman Road.
Royle praised Bent and Ambrose's stunning contribution after they went on for Richard Naylor and Fabian Wilnis.
He said: "The kid Ambrose can make an impact. He ran at them and caused problems.
"Marcus has got all the attributes, he is like a panther when he runs, he is terrific in the air and is a great finisher and once again has score after coming on as a sub.
"I was going to do it at half-time as I felt we were looking tired after the holiday adventures we have had but I wanted to keep the shape with the three centre back a little bit longer.
"The game opened up when they came on but at the same time although our keeper was not too busy we had moments in front of our goal which I don't like. It is a fine balance but four goals at home makes me happy.
"Andy Marshall only had two saves to make but he did them well. Hopefully he has turned the crowd his way. They are fair-minded people but if he carries on playing like that then they will get behind him.
"Tommy Miller was terrific, not just with the two goals. Jamie Clapham was outstanding, not everyone's obvious choice for man of the match but again he was excellent."
Although happy enough with a 4-1 win, Royle still expressed concern at the way the defence struggled when changes were made.
He said: "Their goal was a case of people switching off and mental tiredness. On the positive side we have scored three cracking goals and four in all."
The win extends Town's unbeaten run to six and puts them in 12th place, five points off Reading who are in the last play off place at the moment.
Royle said: "It keeps the run going and while we don't need to rely on other people, the other results went well for us. Things are in our own hands, if we keep winning who knows. It is a fine line between being optimistic and knowing what we want and not getting carried away."
The win came at a cost though, with Thomas Gaardsoe forced off with a groin problem and already ruled out of Saturday's FA Cup tie with Morecambe.
After the substitutions both teams switched from three at the back to a 4-4-2, which Millwall manager Mark McGhee claimed suited them better. He said: "When it went to 1-1, I fancied us. 4-4-2 is more our game and things looked promising, But then we gave away two poor goals.
"We have now given ourselves a lot to do in terms of reaching the play-offs but for Ipswich it is certainly not out of the question for them. They are improving all the time their tempo is good they can pass and most teams in this division will find them hard to beat now."
The day got worse for Millwall supporters travelling home to London, when it was announced the A12 was closed between Marks Tey and Chelmsford. The Town crowd chanted: "4-1 and you can't get home."
The fact that the game went ahead at all was a testament to Ipswich Town groundsman Alan Ferguson and his staff's dedication. Scotsman Ferguson curtailed Hogmanay celebrations to be at Portman Road at 5am to put up the bubble, which protected the pitch and allowed the game to be played, despite torrential rain.

redpajama_set_name: RedPajamaCommonCrawl


text:
Q: NULL function pointer, function declared inside a header file I have a problem handling a function pointer.I have made a class Control that has a function pointer as member:
void (*mouseFunction) (Control*, Event*);

The member is protected, and it has setter and getter:
void (*getMouseFunction()) (Control*,Event*)
{
    return mouseFunction;
}
void setMouseFunction( void (*mouseFunction) (Control*, Event*) )
{
    this->mouseFunction=mouseFunction;
}

The problem is that even after setting the pointer, it's always NULL.
I have a function declared inside a header file:
void mouseFunction (Control* control, Event* event)
{
    std::cout << "Inside Text Field";
}

If I try to assign it:
myControlInstance.setMouseFunction(mouseFunction);

If I use the getter to get the pointer it's NULL; and if I try to execute the function I get EXC_BAD_ACCESS:
error: address doesn't contain a section that points to a section in a object file

A: Following cod is working, so be sure that youre method is public to be accessible from other place than object.
typedef int Event;

class Control
{

public:
    void (*mouseFunction) (Control*, Event*);

    void (*getMouseFunction()) (Control*,Event*)
    {
        return mouseFunction;
    }

    void setMouseFunction( void (*mouseFunction) (Control*, Event*) )
    {
        this->mouseFunction=mouseFunction;
    }
};

void mouseFunction (Control* control, Event* event)
{
    printf ("test");
}

int _tmain(int argc, _TCHAR* argv[])
{

    Control c;
    c.setMouseFunction(mouseFunction);
    Event e = 1;
    c.mouseFunction(&c,&e);
    return 0;
}

A: Your problem might be with inlining.  Since the function is declared and defined at the same point, and inside a header.. the compiler may be treating it as an implicit inline (please note that it is up to the compiler to decide whether or not to actually inline it).  If the function is inlined, then the compiler would have to jump through some extra hoops to make it possible to store a pointer to that function (i.e., the compiler would have to have a non-inline version of the function built).  If the compiler doesn't make this happen, then you're going to have problems storing and calling a function pointer to the function.
To eliminate this as a possible source of the problem, try moving the function's implementation out into a cpp file, which is one common way to prevent implicit inlining (and usually better style anyway).

redpajama_set_name: RedPajamaStackExchange


text:
Home/WizKids
Jeff McAleerFeb 20, 2012
The Hobbit: An Unexpected Journey – Journey to the Lonely Mountain Coming in October
As noted last week, two games from WizKids will tackle the new film The Hobbit: An Unexpected Journey. There isn't…
The Daily Dope for Friday February 17th, 2012
Today's edition is a little late simply because it was a pretty slow gaming news day but there's still plenty…
The Daily Dope for Monday February 13th, 2012
Elliott gets the week rolling along with today's latest from Fantasy Flight Games, Wizards of the Coast, Clash of Arms Games,…
Jeff McAleerJan 30, 2012
Star Trek HeroClix Away Team Lands in July
WizKids is planning a second Star Trek HeroClix release for this July. Seven figures are included in the Star Trek…
The Daily Dope for Thursday January 26th, 2012
Sorry for the late night posting… Here's the latest from WizKids, Fantasy Flight Games, White Dog Games, AEG, and more!…
The Lord of the Rings: Nazgul Board Game Coming from WizKids
WizKids Games announces a semi-co op game set in Middle-earth. The title of this one? The Lord of the Rings:…
The Daily Dope for Tuesday January 17th, 2012
A big thanks to my co-host for taking over duties yesterday (and on future Monday shows) but I'm back in…
The Black Dragon Joins Pathfinder Heroes and Monsters
WizKids has an additional new figure to be made available separate from their Pathfinder Heroes and Monsters boosters now arriving…
June Brings Quarmageddon to Quarriors!
June 2012 brings all new options to Quarriors and even more powerful creatures and spells to use to lay the…
Today's show brings you the latest from Gamewright, Wizkids, Days of Wonder, Fantasy Flight Games, Privateer Press, Pinnacle Entertainment, the…


The head of the Atlantic Council drew a line between the two recent US presidencies, noting that while Barack Obama preferred to steer the US so that it would stand by the EU, Trump is showing a strong vector on reaching "a major deal" with China, despite the challenges that have been popping up along the way.
President and CEO of the Atlantic Council Frederick Kempe, believes that it is critical for the EU and the US to have a common stance on China, although it does not appear to exist at the moment, Kempe told the World News Monitor (WNM) in an interview.
While Italy is about to become the first major EU member state to sign a bilateral agreement on cooperation with the second biggest economy within the framework of the "Belt and Road Initiative" (BRI), Kempe acknowledged that it would be a mistake if EU members went ahead with bilateral deals with China.
"Although it may sound a little utopian, a common transatlantic strategy in dealing with China would be in the best interest of both the US and the EU", Kempe stressed.
"Instead, China comes to the table with the full weight of six times more GDP than that of Italy, which next week could become the first G-7 member state to endorse China's Belt and Road Initiative".
Yet, as Kempe sees it, the US administration itself is not unanimous and not in the least coherent about the approach they have yet to work out with regard to China: whereas President Trump adheres to an exclusively transaction-oriented line, prioritising sales of as many US goods as possible to China, others in the White House seem to be aiming at persuading China to stick to "the international rules of the game", Kempe remarked.
However, Trump's transaction-focused approach is said to pose some risk to the EU, as there are signs today that the US and China could successfully strike a trade deal at the expense of the EU, according to Wolfgang Eder, CEO of the Voestalpine AG, an Austria-based global steel and technology conglomerate, as cited by the WNM. The top manager stressed that it is clear that the BRI in Europe boils down to "a program for the sale of Chinese goods in the EU".
In the aforementioned interview, Kempe pointed to a striking difference in Trump's policies as compared to his predecessor Obama's.
"We are dealing with two very different US presidencies with regard to Europe", Kempe said, adding that while Barack Obama had advocated the "stay behind" principle and was not particularly interested in Europe, Trump, on the other hand, is pursuing a robust policy in which he sees the EU as a competitor in global markets.
Kempe went on to comment that Trump is unlikely to give up his stance on Europe, but instead, clearly prioritises "a big deal" with China, despite the challenges that the two top economies have met up with in their bilateral ties.
Along with the recent Huawei scandal, whereby the US has doubled down on its tries to push the Chinese telecom mammoth from the market and halt its grand 5G aspirations in the western hemisphere, there have been quite a few trade controversies. Against the backdrop of a trade war that has been waged since Trump announced boosted duties on Chinese goods in June, Trump and Chinese President Xi Jinping agreed to go ahead with a 3-month truce to allow room for a new trade agreement back in December, with the truce being further prolonged.


Skagit Island Human Resource Management Association offers sponsorship opportunities to local businesses and consultants at each of our monthly breakfast meetings. This is an opportunity to speak directly to Skagit and Island County Human Resource managers, business owners, managers and other business decision makers SIHRMA meetings are generally held the Second Thursday of each month and run from 7:15 AM to 9:00 AM. They are held at the Skagit Transit Station Community Room in Mount Vernon.
Cost of Sponsorship is $150.00 per meeting and includes one breakfast. Rates may go up in the future.
Listing of your company name and URL on the SIHRMA Website for one year.
For more information or to reserve your sponsorship date, email Ryan.
Skagit-Island Human Resource Management Association hosts an annual Fall Workshop in October of each year. We have excellent attendance, generally around 40 – 60 attendees, and rave reviews from previous workshops.
These workshops feature excellent speakers and catered breakfast. The workshop not only targets the human resource professional, but also managers, supervisors and business owners. You might even consider attending or inviting another person from your company.
We invite you to sponsor a workshop, which will result in exposing your organization to key professionals in Skagit county and surrounding areas for a minimal cost.
You may also donate an item(s) of any value for our Fundraiser Raffle in addition to or in lieu of sponsorship.
For more information on sponsoring this year's Fall Workshop SIHRMA Fall Workshop Sponsorship Agreement (1).docx. The form outlines the specifics for the sponsorship levels. If you have any questions, please contact Anusha.


text:
#import "TMLLanguageCase.h"
#import "TMLLanguageCaseRule.h"
#import "TMLLanguage.h"
#import "TMLAPISerializer.h"

@implementation TMLLanguageCase

- (id)copyWithZone:(NSZone *)zone {
    TMLLanguageCase *aCopy = [[TMLLanguageCase alloc] init];
    aCopy.language = [self.language copyWithZone:zone];
    aCopy.application = [self.application copyWithZone:zone];
    aCopy.keyword = [self.keyword copyWithZone:zone];
    aCopy.latinName = [self.latinName copyWithZone:zone];
    aCopy.nativeName = [self.nativeName copyWithZone:zone];
    aCopy.caseDescription = [self.caseDescription copyWithZone:zone];
    aCopy.rules = [self.rules copyWithZone:zone];
    return aCopy;
}

- (BOOL)isEqual:(id)object {
    if (self == object) {
        return YES;
    }
    if ([object isKindOfClass:[self class]] == NO) {
        return NO;
    }
    return [self isEqualToLanguageCase:(TMLLanguageCase *)object];
}

- (BOOL)isEqualToLanguageCase:(TMLLanguageCase *)languageCase {
    return ((self.language == languageCase.language
             || [self.language isEqualToLanguage:languageCase.language] == YES)
            && (self.application == languageCase.application
                || [self.application isEqualToString:languageCase.application] == YES)
            && (self.caseDescription == languageCase.caseDescription
                || [self.caseDescription isEqualToString:languageCase.caseDescription] == YES)
            && (self.latinName == languageCase.latinName
                || [self.latinName isEqualToString:languageCase.latinName] == YES)
            && (self.nativeName == languageCase.nativeName
                || [self.nativeName isEqualToString:languageCase.nativeName] == YES)
            && (self.rules == languageCase.rules
                || [self.rules isEqualToArray:languageCase.rules] == YES));
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:self.application forKey:@"application"];
    [aCoder encodeObject:self.keyword forKey:@"keyword"];
    [aCoder encodeObject:self.latinName forKey:@"latin_name"];
    [aCoder encodeObject:self.nativeName forKey:@"native_name"];
    [aCoder encodeObject:self.caseDescription forKey:@"description"];
    [aCoder encodeObject:self.rules forKey:@"rules"];
}

- (void)decodeWithCoder:(NSCoder *)aDecoder {
    self.application = [aDecoder decodeObjectForKey:@"application"];
    self.keyword = [aDecoder decodeObjectForKey:@"keyword"];
    self.latinName = [aDecoder decodeObjectForKey:@"latin_name"];
    self.nativeName = [aDecoder decodeObjectForKey:@"native_name"];
    self.caseDescription = [aDecoder decodeObjectForKey:@"description"];
    NSArray *rules = [aDecoder decodeObjectForKey:@"rules"];
    if (rules.count > 0 && [aDecoder isKindOfClass:[TMLAPISerializer class]] == YES) {
        rules = [TMLAPISerializer materializeObject:rules withClass:[TMLLanguageCaseRule class]];
    }
    self.rules = rules;
}

- (NSObject *) findMatchingRule: (NSString *) value {
    return [self findMatchingRule:value forObject:nil];
}

- (NSObject *) findMatchingRule: (NSString *) value forObject: (NSObject *) object {
    for (TMLLanguageCaseRule *rule in self.rules) {
        NSNumber *result = [rule evaluate:value forObject:object];
        if ([result isEqual: @YES])
            return rule;
    }

    return nil;
}

- (NSString *) apply: (NSString *) value {
    return [self apply:value forObject:nil];
}

- (NSString *) apply: (NSString *) value forObject: (NSObject *) object {
    NSArray *elements;

    if ([self.application isEqualToString:@"phrase"]) {
        elements = @[value];
    } else {
        NSString *pattern = @"\\s\\/,;:"; // split by space, comma, ;, : and /
        NSString *tempSeparator = @"%|%";
        NSString *cleanedValue = [value stringByReplacingOccurrencesOfString: pattern
                                                                  withString: tempSeparator
                                                                     options: NSRegularExpressionSearch
                                                                       range: NSMakeRange(0, value.length)];
        elements = [cleanedValue componentsSeparatedByString: tempSeparator];
    }

    // TODO: use RegEx to split words and assemble them right back
    // The current solution will not work for Палиграф Палиграфович -> Палиграфа Палиграфаович

    NSString *transformedValue = [NSString stringWithString:value];
    for (NSString *element in elements) {
        TMLLanguageCaseRule *rule = (TMLLanguageCaseRule *) [self findMatchingRule:element forObject:object];
        if (rule == nil)
            continue;

        NSString *adjustedValue = [rule apply:element];
        transformedValue = [transformedValue stringByReplacingOccurrencesOfString: element
                                                                       withString: adjustedValue
                                                                          options: 0
                                                                            range: NSMakeRange(0, transformedValue.length)];
    }

    return transformedValue;
}

@end

redpajama_set_name: RedPajamaGithub


Milestone Sessions are a perfect choice for a baby's first year or child's yearly portrait sessions. Sessions are for one child only but include multiple backdrops and/or clothing changes. Fee includes the digital download of all images from your online gallery (typically 30-40 photos) with the option to purchase professional prints..
Family sessions focus on capturing the emotion and connection between parents and children and siblings at this moment in time. We will do individuals of each child, sibling shots, parents as well as the group family shots. Fee includes download of all images in your gallery (typicallly 30-40 photos) with the option to purchase professional prints.
Newborn sessions are designed to capture those precious moments in the baby's first couple weeks at home. We will capture individuals, all the little details like hands and feet, and the connection of parents and siblings as they bond with their newest addition. Fee includes digital downloads of all images in your online gallery with the option to purchase professional prints.
Here are some of my favorites from one of the Live Bunny Minisessions I did back in April. This was the second year we did the live bunnies for Easter and they are just the cutest and sweetest things. I have really enjoyed them both years. They are certainly the least intimidating of all the animals and the kids seem to take to them right away.
Hi there! I'm Melissa Toms, a southern girl from Nashville, Tennessee. I'm a natural light photographer specializing in the images of childhood. I love capturing your family's story with the same wonder seen through your child's eyes.
As a mom of 3 boys, I know that the days are long but the years are so short. I strongly believe that the simple, everyday moments add up to magical memories that are worth preserving.
I love to document the tender newborn snuggles, the rowdy toddler phase, and the imagination of those fleeting school years. I would love the opportunity to work together to document your story for you to cherish for years come!
I was born and raised right here in Nashville, TN. I know, I know, I'm like the only one. I couldn't love this city or this state more. The gorgeous rolling hills and colorful sunsets. There is no other place I would rather call home sweet home.
I love being outside, whether it's at the beach, sitting outside at First Tennessee Park taking in a Sounds game or hiking in the Smoky Mountains, I enjoy being outdoorsy more than indoorsy.
I love all kinds of design. Over the past 15 years, I have been lucky to work in interior design, graphic design and photography!


DANBURY, Connecticut – October 25, 2016 - Western Connecticut Health Network (WCHN) has named internationally known physician-scientist, John A. Martignetti, MD, PhD, an expert in human genetics and genomic sciences at the Icahn School of Medicine at Mount Sinai, as the Network Director of the Laboratory for Translational Research at the WCHN Biomedical Research Institute. Under this collaboration, Dr. Martignetti's well-established bedside to bench cancer research methodology will be extended to patients at Danbury, Norwalk and New Milford hospitals leading to more personalized and successful therapeutic strategies. He will work closely with the oncology physicians and research scientists across WCHN to build on their nationally recognized efforts.
Working alongside new colleagues at WCHN, Dr. Martignetti will continue to explore precision medicine strategies to 1) advance the care and treatment of patients with gynecologic cancer and 2) establish effective biomarkers to enable reliable disease surveillance leading to more predictable care pathways. He will also pursue development of novel therapeutics while studying the genetics of hereditary ovarian and breast cancer.
"WCHN offers innovative cancer care that rivals any center in the country," Dr. Thomas Rutherford, WCHN Network Director for Cancer Services said. "As a practitioner, it is very exciting to be working with someone of Dr. Martignetti's reputation and devotion as we collaborate on new ways to beat cancer. I am looking forward to integrating the excellent cancer programs, services, and providers in our cancer care team at WCHN with the exciting research Dr. Martignetti has underway so our patients are served by the most personalized medicine possible."
"We are thrilled to have Dr. Martignetti join the WCHN family and lead our Translational Research team," said WCHN President and CEO Dr. John Murphy. "John has an outstanding reputation for both his clinical and research experience, and he is so deeply committed to solving the needs of those suffering from cancer. His vision and leadership will enhance the great care provided by an excellent cancer team in place today. Working with Dr. Tom Rutherford and our oncology team, his guidance, as we transform cancer care for our communities, will be invaluable."
"I am excited to join the very dedicated and committed cancer team at WCHN and look forward to this partnership that is aimed at revolutionizing oncology research and patient care," said Dr. Martignetti, MD, PhD, Associate Professor of Genetics and Genomic Sciences, Oncological Sciences, Pediatrics, Obstetrics, Gynecology and Reproductive Science at the Icahn School of Medicine at Mount Sinai.
He earned his BA from Columbia College, Columbia University and was awarded his MPhil in molecular biology from Cambridge University. He received his MD and MD, PhD from the Icahn School of Medicine at Mount Sinai in New York and is widely published in the fields of Cancer Genetics, Gene Discovery, Genomics, and Molecular Biology.


text:
package com.evolveum.midpoint.eclipse.ui.handlers.sources;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;

public class SelectionUtils {

	public static List<IFile> getXmlFiles(IStructuredSelection selection) {
		List<IFile> files = new ArrayList<>();
		for (Object item : selection.toList()) {
			if (item instanceof IResource) {
				SelectionUtils.addXmlFiles(files, (IResource) item);
			}
		}
		return files;
	}

	public static List<IFile> getSelectedXmlFiles(ISelection selection) {
		if (selection instanceof ITextSelection) {
			IFile openFile = getFileInActiveEditor(selection);
			if (openFile != null) {
				return Collections.singletonList(openFile);
			}
			return new ArrayList<>();
		}
		if (!(selection instanceof IStructuredSelection)) {
			return new ArrayList<>();
		}
		IStructuredSelection ss = (IStructuredSelection) selection;
		return getXmlFiles(ss);
	}

	public static void addXmlFiles(List<IFile> files, IResource resource) {
		if (resource instanceof IProject && !((IProject) resource).isOpen()) {
			return;
		}
		if (resource instanceof IContainer) {
			try {
				for (IResource member : ((IContainer) resource).members()) {
					addXmlFiles(files, member);
				}
			} catch (CoreException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else if (resource instanceof IFile) {
			IFile file = (IFile) resource;
			if ("XML".equalsIgnoreCase(file.getFileExtension())) {
				files.add(file);
			}
		} else {
			// TODO issue warning
		}
	}

	public static ISelection getSelection(ExecutionEvent event) {
		ISelectionService selectionService = HandlerUtil.getActiveWorkbenchWindow(event).getSelectionService();
		ISelection selection = selectionService.getSelection();
		System.out.println("Current selection: " + selection.getClass());
		return selection;
	}

	public static ISelection getWorkbenchSelection() {
		IWorkbenchWindow win = getActiveWindow();
		if (win == null) {
			return null;
		}
		IWorkbenchPage page = win.getActivePage();
		if (page == null) {
			return null;
		}
		ISelection selection = page.getSelection();
		return selection;
	}

	public static IWorkbenchWindow getActiveWindow() {
		IWorkbench wb = PlatformUI.getWorkbench();
		if (wb == null) {
			return null;
		}
		return wb.getActiveWorkbenchWindow();
	}

	public static IWorkbenchPage getActivePage() {
		IWorkbenchWindow win = getActiveWindow();
		return win != null ? win.getActivePage() : null;
	}

	public static IEditorPart getActiveEditor() {
		IWorkbenchPage activePage = getActivePage();
		return activePage != null ? activePage.getActiveEditor() : null;
	}

	public static ISelectionService getSelectionServiceFromActiveWindow() {
		IWorkbenchWindow win = getActiveWindow();
		return win != null ? win.getSelectionService() : null;
	}

	public static IResource getResourceFromActiveWindow() {
		ISelectionService ss = getSelectionServiceFromActiveWindow();
		if (ss == null) {
			return null;
		}
		return getResourceFromSelection(ss.getSelection());
	}

	public static IProject guessSelectedProjectFromExplorerOrNavigator() {
        ISelectionService ss = getSelectionServiceFromActiveWindow();
        if (ss == null) {
        	return null;
        }

        IResource resExplorer = getResourceFromSelection(ss.getSelection("org.eclipse.ui.navigator.ProjectExplorer"));
        IResource resNavigator = getResourceFromSelection(ss.getSelection("org.eclipse.ui.views.ResourceNavigator"));
        IProject projExplorer = resExplorer != null ? resExplorer.getProject() : null;
        IProject projNavigator = resNavigator != null ? resNavigator.getProject() : null;
        if (projExplorer == null) {
        	return projNavigator;
        } else if (projNavigator == null) {
        	return projExplorer;
        } else if (projExplorer.equals(projNavigator)) {
        	return projExplorer;
        } else {
        	System.out.println("Conflict: " + projExplorer + " vs " + projNavigator);
        	return null;
        }
	}

	public static IResource getResourceFromSelection(ISelection sel) {
		Object selectedObject = sel;
        if (sel instanceof IStructuredSelection) {
        	selectedObject = ((IStructuredSelection)sel).getFirstElement();
        }
        if (selectedObject instanceof IAdaptable) {
        	return (IResource) ((IAdaptable) selectedObject).getAdapter(IResource.class);
        } else {
        	return null;
        }
	}

	public static List<IProject> getProjects() {
		List<IProject> rv = new ArrayList<>();
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
		IProject[] projects = workspaceRoot.getProjects();
		for (int i = 0; i < projects.length; i++) {
			IProject project = projects[i];
			if (project.isOpen()) {
				rv.add(project);
			}
		}
		return rv;
	}

	public static IFile getFileInActiveEditor(ISelection selection) {
		if (!(selection instanceof ITextSelection)) {
			return null;
		}
		String text = ((ITextSelection) selection).getText();
		IEditorPart activeEditor = getActiveEditor();
		if (activeEditor == null) {
			return null;
		}
		IEditorInput editorInput = activeEditor.getEditorInput();
		if (!(editorInput instanceof FileEditorInput)) {
			return null;
		}
		IFile file = ((FileEditorInput) editorInput).getFile();
		if (StringUtils.isEmpty(text)) {
			return file;
		}
		IDocument doc = (IDocument)activeEditor.getAdapter(IDocument.class);
		if (doc == null) {
			return null;
		}
		String allText = doc.get();
		if (text.equals(allText)) {
			return file;
		}
		// only part of file is selected
		return null;
	}

	public static IProject guessSelectedProject(ISelection selection, String defaultName) {
		List<IFile> files = getSelectedXmlFiles(selection);
		if (!files.isEmpty()) {
			return files.get(0).getProject();
		}
		IResource resource = getResourceFromActiveWindow();
		if (resource != null) {
			return resource.getProject();
		}
		IProject project = guessSelectedProjectFromExplorerOrNavigator();
		if (project != null) {
			return project;
		}
		if (StringUtils.isNotBlank(defaultName)) {
			if ("*".equals(defaultName)) {
				IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
				for (IProject p : projects) {
					if (p.isOpen()) {
						return p;
					}
				}
			} else {
				IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(defaultName);
				if (p != null && p.exists()) {
					return p;
				}
			}
		}
		return null;
	}

	public static class CursorPosition {
		public final int line, column;
		public CursorPosition(int line, int column) {
			this.line = line;
			this.column = column;
		}
		@Override
		public String toString() {
			return "CursorPosition [line=" + line + ", column=" + column + "]";
		}
	}

	public static CursorPosition getCursorPosition() {
		// TODO ok?
		IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
        IWorkbenchPage page = win != null ? win.getActivePage() : null;
        IEditorPart editor = page != null ? page.getActiveEditor() : null;
        Control control = editor.getAdapter(Control.class);
        if (editor instanceof ITextEditor && control instanceof StyledText) {
        	IDocumentProvider provider = ((ITextEditor)editor).getDocumentProvider();
        	IDocument document = provider.getDocument(editor.getEditorInput());
        	try {
        		StyledText styledText = (StyledText) control;
        		int caret = styledText.getCaretOffset();
        		int line = document.getLineOfOffset(caret);
        		int lineOffset = document.getLineOffset(line);
       			int tabWidth = styledText.getTabs();
       			int column = 0;
       			for (int i = lineOffset; i < caret; i++) {
       				if (document.getChar(i) == '\t') {
        				column += tabWidth - (tabWidth == 0 ? 0 : column % tabWidth);
       				} else {
        				column++;
       				}
       			}
                return new CursorPosition(line, column);
        	} catch (BadLocationException e) {
                e.printStackTrace();
            }
        } else {
        	System.out.println("Couldn't determine column, for editor=" + editor + ", control=" + control);
        }

        return null;
	}

}


NEW YORK — Wi-Fi on subway lines and stations throughout New York have been tested for best overall service on mobile phones, and some have proven much better than others.
Global Wireless Solutions released data from their latest subway testing that showed that riders on the Q line are able to connect the easiest– with that line achieving the best overall service on mobile phones.
The 6 line came in a close second for the best overall service and the R line came in third. The worst lines were the Z, J and 5.
The stations with the strongest signals are the Fifth Avenue 59th Street N/Q/R, and the 53rd Street E/M. The slowest connection is at the Lexington Avenue 53rd Street station, followed by the 116th Street A/B/C, and the Fulton Street J/Z stop.
"Our carefully controlled tests examined a variety of metrics, including upload and download speeds and task attempts and completions, to determine just how successful this rollout has been so far and which lines commuters can expect to have the easiest experience getting online" Dr. Paul Carter, CEO at Global Wireless Solutions said.
According to GWS, the current use of the NYC subway is at highest in the past 60 years with more than 1.7 billion riders each year.
The MTA says that all 277 subway stations in the city will enjoy free Internet access by 2017.


RF cables -Semi-rigid 0.047 cables of RFCT are the best choice for RF microwave transmission available. The solid tubular outer conductor yields 100% RF shielding and enables the dielectric and center conductor to remain precisely spaced. This results in optimum impedance control as well as the lowest possible I/L and weight to size ratios. The basic considerations for using semi-rigid are the availability of bend tooling, the difficulty in routing and the need to reform the cable.
Aluminum jacked cables, which are typically tin-plated for solderability enable repeated bending and hand forming. They are excellent choices when the performance of semi-rigid is required, together with flexibility to hand-form in place.


Renewal arrives every Sunday! Are you ready? For some communication with another will bring the love of God to you. This week the 'narrow gate' in the Gospel may be thru marriage. A life long marriage is a great hope for the community. Mentioned in last week's post: 'The Journey of Our Love-The Letters of Saint Gianna Beretta and Pietro Molla' will be a recommended summer reading. In face of acts against love to bask in the communion of love is a remedy. In one letter Pietro wrote to his expectant wife: 'This morning too in our little church next to you, I renewed my most fervent thanks to Jesus for the immeasurable gift of you as my wife, of Pierluigi, Mariolina, and the new little one in your womb. I have always rejoiced to find in you the ideal wife I dreamed of, and an incomparable mother to our children. I am still finding in you new virtues of sacrifice, patience, understanding, and goodness, and always of so much loving affection." (P. 155). May we pray for all men to respect every woman as made in the image of God. For traveling spouses may thoughts of the home and faces of loved ones waiting for your return fill your heart. May God grant perseverance to those awaiting the love of their spouse, chosen by God for their journey of faith in this life. St. Gianna, pray for us!