本文整理汇总了Java中org.eclipse.osgi.service.datalocation.Location.set方法的典型用法代码示例。如果您正苦于以下问题:Java Location.set方法的具体用法?Java Location.set怎么用?Java Location.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.osgi.service.datalocation.Location
的用法示例。
在下文中一共展示了Location.set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignPlatformLocation
import org.eclipse.osgi.service.datalocation.Location; //导入方法依赖的package包/类
protected void assignPlatformLocation() {
Location location = Platform.getInstanceLocation();
if (location.isSet()) {
return;
}
try {
URL platformLocation = initializePlatformLocation("camundaModeler");
// we use toURL here because it properly handles whitespaces
// (in opposite to toURI())
location.set(platformLocation, false);
} catch (IOException e) {
throw new IllegalStateException("Failed to start Modeler", e);
}
}
示例2: start
import org.eclipse.osgi.service.datalocation.Location; //导入方法依赖的package包/类
public Object start(IApplicationContext context) throws Exception{
OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor();
Display display = PlatformUI.createDisplay();
display.addListener(SWT.OpenDocument, openDocProcessor);
try {
Location instanceLoc = Platform.getInstanceLocation();
if(!instanceLoc.allowsDefault() && !instanceLoc.isSet()) {
// get the last used workspace location
String lastUsedWs = PickWorkspaceDialog.getLastSetWorkspaceDirectory();
// usually do not show pickup dialog at startup
boolean showPickupDialog = false;
// check to ensure the workspace location is still OK
// if there's any problem whatsoever with the workspace, force a dialog which in its turn will tell them what's bad
String ret = PickWorkspaceDialog.checkWorkspaceDirectory(Display.getDefault().getActiveShell(), lastUsedWs, false, false);
if (ret != null) {
showPickupDialog = true;
}
logInfo("showPickupDialog=" + showPickupDialog);
logInfo("lastUsedWs=" + lastUsedWs);
logInfo("ret=" + ret);
if (showPickupDialog) {
PickWorkspaceDialog pwd = new PickWorkspaceDialog(false,Activator.getDefault().getImage("icons/jss_icon_64.png"));
int pick = pwd.open();
// if the user cancelled, we can't do anything as we need a workspace, so in this case, we tell them and exit
if (pick == Window.CANCEL) {
if (pwd.getSelectedWorkspaceLocation() == null) {
MessageDialog.openError(display.getActiveShell(), "Error",
"The application can not start without a workspace root and will now exit.");
try {
PlatformUI.getWorkbench().close();
} catch (Exception err) {
}
System.exit(0);
return IApplication.EXIT_OK;
}
}
else {
// tell Eclipse what the selected location was and continue
logInfo("setting from last selected location: " + pwd.getSelectedWorkspaceLocation());
instanceLoc.set(new URL("file", null, pwd.getSelectedWorkspaceLocation()), false);
}
}
else {
// set the last used location and continue
logInfo("setting from last used location: " + lastUsedWs);
instanceLoc.set(new URL("file", null, lastUsedWs), false);
}
}
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor(openDocProcessor));
if (returnCode != PlatformUI.RETURN_RESTART) return EXIT_OK;
return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH : EXIT_RESTART; }
finally {
display.dispose();
}
}
示例3: start
import org.eclipse.osgi.service.datalocation.Location; //导入方法依赖的package包/类
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
try {
Location instanceLoc = Platform.getInstanceLocation();
// get what the user last said about remembering the workspace
// location
boolean remember = PickWorkspaceDialog.isRememberWorkspace();
// get the last used workspace location
String lastUsedWs = PickWorkspaceDialog.getLastSetWorkspaceDirectory();
// if we have a "remember" but no last used workspace, it's not much
// to remember
if (remember && ((lastUsedWs == null) || (lastUsedWs.length() == 0))) {
remember = false;
}
// check to ensure the workspace location is still OK
if (remember) {
// if there's any problem whatsoever with the workspace, force a
// dialog which in its turn will tell them what's bad
String ret = PickWorkspaceDialog.checkWorkspaceDirectory(Display.getDefault().getActiveShell(), lastUsedWs, false, false);
if (ret != null) {
remember = false;
}
}
// if we don't remember the workspace, show the dialog
if (!remember) {
PickWorkspaceDialog pwd = new PickWorkspaceDialog(false, null);
int pick = pwd.open();
// if the user cancelled, we can't do anything as we need a
// workspace, so in this case, we tell them and exit
if (pick == Window.CANCEL) {
if (pwd.getSelectedWorkspaceLocation() == null) {
MessageDialog.openError(display.getActiveShell(), "Error", "The application can not start without a study workspace directory and will now exit.");
// try {
// PlatformUI.getWorkbench().close();
// } catch (Exception err) {
// err.printStackTrace();
// }
System.exit(0);
return IApplication.EXIT_OK;
}
} else {
// tell Eclipse what the selected location was and continue
instanceLoc.set(new URL("file", null, pwd.getSelectedWorkspaceLocation()), false);
}
} else {
// set the last used location and continue
instanceLoc.set(new URL("file", null, lastUsedWs), false);
}
// this is the normal default code from here on out
ResourceLoader.setBundle(Locale.getDefault());
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} catch (Exception ex) {
ex.printStackTrace();
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
示例4: startWithWorkspaceSelection
import org.eclipse.osgi.service.datalocation.Location; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private Object startWithWorkspaceSelection() throws Exception
{
Display display = PlatformUI.createDisplay();
Location instanceLocation = Platform.getInstanceLocation();
try
{
// the "select-workspace" logic is based on the article http://hexapixel.com/2009/01/12/rcp-workspaces
// get what the user last said about remembering the workspace location
boolean remember = PickWorkspaceDialog.isRememberWorkspace();
// get the last used workspace location
String lastUsedWs = PickWorkspaceDialog.getLastSetWorkspaceDirectory();
// if we have a "remember" but no last used workspace, it's not much to remember
if (remember && (lastUsedWs == null || lastUsedWs.length() == 0)) {
remember = false;
}
// check to ensure the workspace location is still OK
if (remember)
{
// if there's any problem whatsoever with the workspace, force a dialog which in its turn will tell them what's bad
String ret = PickWorkspaceDialog.checkWorkspaceDirectory(Display.getDefault().getActiveShell(), lastUsedWs, false, false);
if (ret != null) {
remember = false;
}
}
// if we don't remember the workspace, show the dialog
if (!remember)
{
PickWorkspaceDialog pwd = new PickWorkspaceDialog(false, null);
int pick = pwd.open();
// if the user cancelled, we can't do anything as we need a workspace, so in this case, we tell them and exit
if (pick == Window.CANCEL)
{
if (pwd.getSelectedWorkspaceLocation() == null)
{
MessageDialog.openError(display.getActiveShell(), "Error", "The application can not start without a workspace root and will now exit.");
try { PlatformUI.getWorkbench().close(); }
catch (Exception err) { System.exit(0); }
return IApplication.EXIT_OK;
}
}
else
{
// tell Eclipse what the selected location was and continue
instanceLocation.set(new URL("file", null, pwd.getSelectedWorkspaceLocation()), false);
}
}
else
{
// set the last used location and continue
instanceLocation.set(new URL("file", null, lastUsedWs), false);
}
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
} else {
return IApplication.EXIT_OK;
}
}
finally
{
display.dispose();
}
}