org.eclipse.osgi.util.NLS Java Examples

The following examples show how to use org.eclipse.osgi.util.NLS. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenAppAction.java    From codewind-eclipse with Eclipse Public License 2.0 8 votes vote down vote up
public static void openAppInBrowser(CodewindApplication app) {
	URL appRootUrl = app.getRootUrl();
	if (appRootUrl == null) {
		Logger.logError("The application could not be opened in the browser because the url is null: " + app.name); //$NON-NLS-1$
		return;
	}
	try {
		// Use the app's ID as the browser ID so that if this is called again on the same app,
		// the browser will be re-used
		IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		IWebBrowser browser = browserSupport
				.createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR,
						app.projectID, app.name, NLS.bind(Messages.BrowserTooltipApp, app.name));

		browser.openURL(appRootUrl);
	} catch (PartInitException e) {
		Logger.logError("Error opening app in browser", e); //$NON-NLS-1$
	}
}
 
Example #2
Source File: ConnectDisconnectAction.java    From codewind-eclipse with Eclipse Public License 2.0 7 votes vote down vote up
public static void connectRemoteCodewind(RemoteConnection conn) {
	Job job = new Job(NLS.bind(Messages.ConnectJobLabel, conn.getBaseURI())) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				conn.connect(monitor);
				CodewindUIPlugin.getUpdateHandler().updateConnection(conn);
				return Status.OK_STATUS;
			} catch (Exception e) {
				Logger.logError("An error occurred connecting to: " + conn.getBaseURI(), e); //$NON-NLS-1$
				return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ConnectJobError, conn.getBaseURI()), e);
			}
		}
	};
	job.schedule();
}
 
Example #3
Source File: NewCodewindConnectionWizard.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean performFinish() {
	if(!canFinish()) {
		return false;
	}

	Job job = new Job(NLS.bind(Messages.NewConnectionWizard_CreateJobTitle, newConnectionPage.getConnectionName())) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			return newConnectionPage.createConnection(monitor);
		}
	};
	job.schedule();

	return true;
}
 
Example #4
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void buildComplete() {
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
   	if (project != null && project.isAccessible()) {
   		Job job = new Job(NLS.bind(Messages.RefreshResourceJobLabel, project.getName())) {
			@Override
			protected IStatus run(IProgressMonitor monitor) {
				try {
					project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
		            return Status.OK_STATUS;
				} catch (Exception e) {
					Logger.logError("An error occurred while refreshing the resource: " + project.getLocation()); //$NON-NLS-1$
					return new Status(IStatus.ERROR, CodewindCorePlugin.PLUGIN_ID,
							NLS.bind(Messages.RefreshResourceError, project.getLocation()), e);
				}
			}
		};
		job.setPriority(Job.LONG);
		job.schedule();
   	}
}
 
Example #5
Source File: Dashboard.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
private void ignoreMergeUnit(IMergeUnit mergeUnit) {
	LogUtil.entering(mergeUnit);

	MergeUnitStatus status = mergeUnit.getStatus();
	if (status == MergeUnitStatus.DONE) {
		String dialogMessage = NLS.bind(Messages.View_IgnoreSelection_Done_Question, mergeUnit.getFileName(),
				status);
		MessageDialog dialog = new MessageDialog(shell, Messages.View_IgnoreSelection_Done_Title, null,
				dialogMessage, MessageDialog.QUESTION,
				new String[] { Messages.View_IgnoreSelection_Done_Yes, Messages.View_IgnoreSelection_Done_No }, 0);

		int choice = dialog.open();

		if (choice != 0) {
			// user didn't say 'yes' so we skip it...
			LogUtil.getLogger().fine(() -> String.format("User skipped mergeUnit=%s with status %s.", mergeUnit, //$NON-NLS-1$
					mergeUnit.getStatus()));
			return;
		}
	}

	LogUtil.getLogger().fine(() -> String.format("Ignoring mergeUnit=%s", mergeUnit));
	MergeProcessorUtil.ignore(mergeUnit);
	LogUtil.exiting();
}
 
Example #6
Source File: SVNMergeUtil.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
private static void deleteLocal(SVNMergeUnit mergeUnit) {
	LogUtil.entering(mergeUnit);

	File file = new File(Configuration.getPathLocalMergeFile(mergeUnit));
	LOGGER.fine(() -> String.format("Deleting local merge file=%s.", file.getAbsolutePath())); //$NON-NLS-1$
	boolean success = !file.exists();
	while (!success) {
		success = file.delete();
		if (!success) {
			String messageScrollable = NLS.bind(Messages.MergeProcessorUtil_DeleteLocal_Error_Message,
					file.getAbsolutePath());
			if (MergeProcessorUtil.bugUserToFixProblem(Messages.MergeProcessorUtil_DeleteLocal_Error_Title,
					messageScrollable)) {
				LOGGER.fine(() -> String.format("User wants to retry deleting local merge file. mergeUnit=%s.", //$NON-NLS-1$
						mergeUnit));
			} else {
				LOGGER.fine(
						() -> String.format("User cancelled deleting local merge file. mergeUnit=%s.", mergeUnit)); //$NON-NLS-1$
				success = true;
			}
		}
	}
	LogUtil.exiting();
}
 
Example #7
Source File: Auditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void handleCheckstyleFailure(IProject project, CheckstyleException e)
        throws CheckstylePluginException {
  try {

    CheckstyleLog.log(e);

    // remove pre-existing project level marker
    project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);

    Map<String, Object> attrs = new HashMap<>();
    attrs.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL));
    attrs.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
    attrs.put(IMarker.MESSAGE, NLS.bind(Messages.Auditor_msgMsgCheckstyleInternalError, null));

    IMarker projectMarker = project.createMarker(CheckstyleMarker.MARKER_ID);
    projectMarker.setAttributes(attrs);
  } catch (CoreException ce) {
    CheckstylePluginException.rethrow(e);
  }
}
 
Example #8
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void deleteProject() {
	Job job = new Job(NLS.bind(Messages.DeleteProjectJobLabel, name)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				IProject project = CoreUtil.getEclipseProject(CodewindEclipseApplication.this);
				if (project != null) {
					project.delete(true, true, monitor);
				} else if (fullLocalPath.toFile().exists()) {
					FileUtil.deleteDirectory(fullLocalPath.toOSString(), true);
				} else {
					Logger.log("No project contents were found to delete for application: " + name);
				}
			} catch (Exception e) {
				Logger.logError("Error deleting project contents: " + name, e); //$NON-NLS-1$
				return new Status(IStatus.ERROR, CodewindCorePlugin.PLUGIN_ID, NLS.bind(Messages.DeleteProjectError, name), e);
			}
			if (monitor.isCanceled()) {
				return Status.CANCEL_STATUS;
			}
			return Status.OK_STATUS;
		}
	};
	job.schedule();
}
 
Example #9
Source File: ProjectUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void createProject(String name, String path, String url, String conid, IProgressMonitor monitor) throws IOException, JSONException, TimeoutException {
	SubMonitor mon = SubMonitor.convert(monitor, NLS.bind(Messages.CreateProjectTaskLabel, name), 100);
	Process process = null;
	try {
		process = CLIUtil.runCWCTL(CLIUtil.GLOBAL_JSON_INSECURE, CREATE_CMD, new String[] {PATH_OPTION, path, URL_OPTION, url, CLIUtil.CON_ID_OPTION, conid});
		ProcessResult result = ProcessHelper.waitForProcess(process, 500, 600, mon);
		CLIUtil.checkResult(CREATE_CMD, result, true);
		JSONObject resultJson = new JSONObject(result.getOutput());
		if (!CoreConstants.VALUE_STATUS_SUCCESS.equals(resultJson.getString(CoreConstants.KEY_STATUS))) {
			String msg = "Project create failed for project: " + name + " with output: " + result.getOutput(); //$NON-NLS-1$ //$NON-NLS-2$
			Logger.logError(msg);
			throw new IOException(msg);
		}
	} finally {
		if (process != null && process.isAlive()) {
			process.destroy();
		}
	}
}
 
Example #10
Source File: CheckConfigurationWorkingCopy.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Changes the name of the check configuration.
 *
 * @param name
 *          the new name
 * @throws CheckstylePluginException
 *           if name is <code>null</code> or empty or a name collision with an existing check
 *           configuration exists
 */
public void setName(String name) throws CheckstylePluginException {

  if (name == null || name.trim().length() == 0) {
    throw new CheckstylePluginException(Messages.errorConfigNameEmpty);
  }

  String oldName = getName();
  if (!name.equals(oldName)) {

    mEditedName = name;

    // Check if the new name is in use
    if (mWorkingSet.isNameCollision(this)) {
      mEditedName = oldName;
      throw new CheckstylePluginException(NLS.bind(Messages.errorConfigNameInUse, name));
    }
  }
}
 
Example #11
Source File: RemoteEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void launchTerminated(ILaunch launch) {
	if (debugPFInfo != null && launch == debugPFInfo.launch) {
		// The user terminated the port forwarding
		IPreferenceStore prefs = CodewindCorePlugin.getDefault().getPreferenceStore();
		if (!prefs.getBoolean(NOTIFY_PORT_FORWARD_TERMINATED_PREFSKEY)) {
			Display.getDefault().asyncExec(() -> {
				MessageDialogWithToggle portForwardEndDialog = MessageDialogWithToggle.openInformation(Display.getDefault().getActiveShell(),
						Messages.PortForwardTerminateTitle,
						NLS.bind(Messages.PortForwardTerminateMsg, new String[] {name, connection.getName(), Integer.toString(debugPFInfo.remotePort)}),
						Messages.PortForwardTerminateToggleMsg, false, null, null);
				prefs.setValue(NOTIFY_PORT_FORWARD_TERMINATED_PREFSKEY, portForwardEndDialog.getToggleState());
			});
		}
		debugPFInfo = null;
		CoreUtil.updateApplication(this);
	} else if (launch == getLaunch()) {
		// Make sure the port forward process is terminated
		if (debugPFInfo != null) {
			debugPFInfo.terminate();
			debugPFInfo = null;
		}
		CoreUtil.updateApplication(this);
	}
}
 
Example #12
Source File: ComplexFileSetsEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addFileSet() {
  try {
    FileSetEditDialog dialog = new FileSetEditDialog(mComposite.getShell(), null, mProject,
            mPropertyPage);
    if (Window.OK == dialog.open()) {
      FileSet fileSet = dialog.getFileSet();
      mFileSets.add(fileSet);
      mViewer.refresh();
      mViewer.setChecked(fileSet, fileSet.isEnabled());

      mPropertyPage.getContainer().updateButtons();
    }
  } catch (CheckstylePluginException e) {
    CheckstyleUIPlugin.errorDialog(mComposite.getShell(),
            NLS.bind(Messages.errorFailedAddFileset, e.getMessage()), e, true);
  }
}
 
Example #13
Source File: LinkManagementComposite.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private boolean validate() {
	if (projectList.getSelectionCount() == 0) {
		setErrorMessage(Messages.LinkMgmtAddDialogNoProject);
		return false;
	}
	if (envVarText.getText() == null || envVarText.getText().trim().isEmpty()) {
		setErrorMessage(Messages.LinkMgmtAddDialogNoEnvVar);
		return false;
	}
	if (!envVarPattern.matcher(envVarText.getText().trim()).matches()) {
		setErrorMessage(NLS.bind(Messages.LinkMgmtAddDialogEnvVarInvalid, envVarRegex));
		return false;
	}
	Optional<LinkEntry> entry = getLinkEntry((String) projectList.getSelection()[0], envVarText.getText().trim());
	if (entry.isPresent()) {
		setErrorMessage(NLS.bind(Messages.LinkMgmtAddDialogLinkExist, projectList.getSelection()[0], envVarText.getText().trim()));
		return false;
	}
	
	setErrorMessage(null);
	return true;
}
 
Example #14
Source File: AddTemplateSourceWizard.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public IWizardPage getNextPage(IWizardPage page) {
	if (page == urlPage) {
		// Check that the URL is valid
		try {
			new URI(urlPage.getTemplateSourceUrl());
		} catch (URISyntaxException e) {
			IDEUtil.openInfoDialog(Messages.AddRepoDialogInvalidUrlTitle, NLS.bind(Messages.AddRepoDialogInvalidUrlError, e.toString()));
			urlPage.setErrorMessage(Messages.AddRepoDialogInvalidUrlMsg);
			return urlPage;
		}
		
		detailsPage.updatePage(urlPage.getTemplateSourceUrl(), urlPage.getAuthInfo());
		return detailsPage;
	}
	return super.getNextPage(page);
}
 
Example #15
Source File: LinkManagementDialog.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent) {
	setTitleImage(CodewindUIPlugin.getImage(CodewindUIPlugin.CODEWIND_BANNER));
	setTitle(Messages.LinkMgmtDialogTitle);
	setMessage(NLS.bind(Messages.LinkMgmtDialogMessage, srcApp.name));
	
	Composite content = (Composite) super.createDialogArea(parent);
	content.setLayout(new GridLayout());
	content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	
	linkComposite = new LinkManagementComposite(content, srcApp);
	GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);
	data.widthHint = 250;
	linkComposite.setLayoutData(data);

	return parent; 
}
 
Example #16
Source File: CodewindInstall.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static Runnable addExistingProjectPrompt(IProject project) {
	return new Runnable() {
		@Override
		public void run() {
			Shell shell = Display.getDefault().getActiveShell();
			if (MessageDialog.openQuestion(shell, Messages.InstallCodewindDialogTitle,
					NLS.bind(Messages.InstallCodewindAddProjectMessage, project.getName()))) {
				CodewindConnection connection = CodewindConnectionManager.getLocalConnection();
				if (connection != null && connection.isConnected()) {
					Wizard wizard = new BindProjectWizard(connection, project);
					WizardLauncher.launchWizardWithoutSelection(wizard);
				} else {
					Logger.logError("Codewind not installed or has unknown status when trying to bind project: " + project.getName()); //$NON-NLS-1$
				}
			}
		}
	};
}
 
Example #17
Source File: ManageLinksAction.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void openManageLinksDialog(CodewindApplication app) {
	try {
		LinkManagementDialog linkDialog = new LinkManagementDialog(Display.getDefault().getActiveShell(), app);
		if (linkDialog.open() == Window.OK && linkDialog.hasChanges()) {
			Job job = new Job(Messages.LinkUpdateTask) {
				@Override
				protected IStatus run(IProgressMonitor monitor) {
					return linkDialog.updateLinks(monitor);
				}
			};
			job.schedule();
		}
	} catch (Exception e) {
		MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.LinkListErrorTitle, NLS.bind(Messages.LinkListErrorMsg, e));
	}
}
 
Example #18
Source File: RemoveConnectionAction.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void run() {
	if (connection == null) {
		// should not be possible
		Logger.logError("RemoveConnectionAction ran but no connection was selected"); //$NON-NLS-1$
		return;
	}

	// Verify that the user wants to remove the connection
	if (!MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.RemoveConnectionActionConfirmTitle,
			NLS.bind(Messages.RemoveConnectionActionConfirmMsg, new String[] {connection.getName(), connection.getBaseURI().toString()}))) {
		return;
	}
	try {
		CodewindConnectionManager.remove(connection.getBaseURI().toString());
	} catch (Exception e) {
		Logger.logError("Error removing connection: " + connection.getBaseURI().toString(), e); //$NON-NLS-1$
	}
}
 
Example #19
Source File: RestartRunModeAction.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
  public void run() {
      if (app == null) {
      	// should not be possible
      	Logger.logError("RestartRunModeAction ran but no application was selected"); //$NON-NLS-1$
	return;
}

// Clear out any old launch and debug target
app.clearDebugger();

Job job = new Job(NLS.bind(Messages.RestartInRunModeTask, app.name)) {
	@Override
	protected IStatus run(IProgressMonitor monitor) {
		try {
			// Restart the project in run mode
			ProjectUtil.restartProject(app.name, app.projectID, StartMode.RUN.startMode, app.connection.getConid(), monitor);
			return Status.OK_STATUS;
		} catch (Exception e) {
			Logger.logError("Error initiating restart for project: " + app.name, e); //$NON-NLS-1$
			return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnRestartMsg, app.name), e);
		}
	}
};
job.schedule();
  }
 
Example #20
Source File: EnableDisableAutoBuildAction.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void enableDisableAutoBuild(CodewindApplication app, boolean enable) {
	Job job = new Job(NLS.bind(Messages.EnableDisableAutoBuildJob, app.name)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				String actionKey = enable ? CoreConstants.VALUE_ACTION_ENABLEAUTOBUILD : CoreConstants.VALUE_ACTION_DISABLEAUTOBUILD;
				app.connection.requestProjectBuild(app, actionKey);
				app.setAutoBuild(enable);
				return Status.OK_STATUS;
			} catch (Exception e) {
				Logger.logError("An error occurred changing auto build setting for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
				return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnEnableDisableAutoBuild, app.name), e);
			}
		}
	};
	job.schedule();
}
 
Example #21
Source File: EnableDisableInjectMetricsAction.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void enableDisableInjectMetrics(CodewindApplication app, boolean enable) {
	Job job = new Job(NLS.bind(Messages.EnableDisableInjectMetricsJob, app.name)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				app.connection.requestInjectMetrics(app.projectID, enable);
				app.connection.refreshApps(app.projectID);
				return Status.OK_STATUS;
			} catch (Exception e) {
				Logger.logError("An error occurred changing inject metric setting for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
				return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnEnableDisableInjectMetrics, app.name), e);
			}
		}
	};
	job.schedule();
}
 
Example #22
Source File: BindProjectWizard.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void cleanup(String projectName, CodewindConnection connection) {
	Job job = new Job(NLS.bind(Messages.ProjectCleanupJobLabel, projectName)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			SubMonitor mon = SubMonitor.convert(monitor, 30);
			mon.split(10);
			connection.refreshApps(null);
			CodewindApplication app = connection.getAppByName(projectName);
			if (app != null) {
				try {
					ProjectUtil.removeProject(app.name, app.projectID, mon.split(20));
				} catch (Exception e) {
					Logger.logError("An error occurred while trying to remove the project after bind project terminated for: " + projectName, e);
					return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ProjectCleanupError, projectName), null);
				}
			}
			return Status.OK_STATUS;
		}
	};
	job.schedule();
}
 
Example #23
Source File: BindProjectWizard.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private boolean checkRemoteStatus() {
	// Try to connect if disconnected
	if (!connection.isConnected()) {
		connectCodewind(connection, this);
	}
	
	// If still not connected then display an error dialog
	if (!connection.isConnected()) {
		CoreUtil.openDialog(true, Messages.BindProjectErrorTitle, NLS.bind(Messages.BindProjectConnectionError, connection.getName()));
		return false;
	}
	
	// Check for project errors (project is already deployed on the connection)
	String projectError = getProjectError(connection, project);
	if (projectError != null) {
		CoreUtil.openDialog(true, Messages.BindProjectErrorTitle, projectError);
		return false;
	}
	
	return true;
}
 
Example #24
Source File: EditConnectionDialog.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent) {
	setTitleImage(CodewindUIPlugin.getImage(CodewindUIPlugin.CODEWIND_BANNER));
	setTitle(Messages.EditConnectionDialogTitle);
	setMessage(NLS.bind(Messages.EditConnectionDialogMessage, connection.getName()));
	
	Composite content = (Composite) super.createDialogArea(parent);
	content.setLayout(new GridLayout(1, false));
	content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	
	connectionComp = new CodewindConnectionComposite(content, this, connection);
	connectionComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	layout.marginHeight = 10;
	layout.marginWidth = 20;
	progressMon = new ProgressMonitorPart(parent, layout, true);
	progressMon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	progressMon.setVisible(false);
	
	return parent;
}
 
Example #25
Source File: ProjectConfigurationFactory.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static IProjectConfiguration getProjectConfiguration(InputStream in, IProject project)
        throws DocumentException, CheckstylePluginException {

  SAXReader reader = new SAXReader();
  Document document = reader.read(in);

  Element root = document.getRootElement();

  String version = root.attributeValue(XMLTags.FORMAT_VERSION_TAG);
  if (!SUPPORTED_VERSIONS.contains(version)) {
    throw new CheckstylePluginException(NLS.bind(Messages.errorUnknownFileFormat, version));
  }

  boolean useSimpleConfig = Boolean.valueOf(root.attributeValue(XMLTags.SIMPLE_CONFIG_TAG))
          .booleanValue();
  boolean syncFormatter = Boolean.valueOf(root.attributeValue(XMLTags.SYNC_FORMATTER_TAG))
          .booleanValue();

  List<ICheckConfiguration> checkConfigs = getLocalCheckConfigs(root, project);
  List<FileSet> fileSets = getFileSets(root, checkConfigs);
  List<IFilter> filters = getFilters(root);

  return new ProjectConfiguration(project, checkConfigs, fileSets, filters, useSimpleConfig,
          syncFormatter);
}
 
Example #26
Source File: SVNMergeUtil.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
private static boolean mergeChangesIntoWorkingCopy(final SVNMergeUnit mergeUnit, final ISvnClient client) {
	LogUtil.entering(mergeUnit);

	boolean cancel = false;
	boolean success = false;
	while (!cancel && !success) {
		try {
			SvnUtil.mergeChanges(mergeUnit, client);
			success = true;
		} catch (SvnUtilException e) {
			LOGGER.log(Level.WARNING, "Caught exception while merging changes into working copy.", e); //$NON-NLS-1$
			String messageScrollable = NLS.bind(
					Messages.MergeProcessorUtil_MergeChangesIntoWorkingCopy_Error_Message_Prefix, e.getMessage());
			if (MergeProcessorUtil.bugUserToFixProblem(
					Messages.MergeProcessorUtil_MergeChangesIntoWorkingCopy_Error_Title, messageScrollable)) {
				// user wants to retry
				LOGGER.fine(String.format("User wants to retry merging changes into working copy for mergeUnit=%s.", //$NON-NLS-1$
						mergeUnit));
				continue;
			} else {
				// user didn't say 'retry' so we cancel the whole merge...
				LOGGER.fine(String.format("User cancelled merging changes into working copy for mergeUnit=%s.", //$NON-NLS-1$
						mergeUnit));
				cancel = true;
			}
		}
	}

	if (!success) {
		// if we haven't had success we cancel. we can't continue without success.
		cancel = true;
	}

	return LogUtil.exiting(cancel);
}
 
Example #27
Source File: HideAllLogsAction.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
  public void run() {
      if (app == null) {
      	// should not be possible
      	Logger.logError("HideAllLogsAction ran but no application was selected"); //$NON-NLS-1$
	return;
}
      
      if (app.getLogInfos() == null || app.getLogInfos().isEmpty()) {
      	Logger.logError("HideAllLogsAction ran but there are no logs for the selected application: " + app.name); //$NON-NLS-1$
      	return;
      }
      
      // Remove any existing consoles for this app
      Job job = new Job(NLS.bind(Messages.HideAllLogFilesJobLabel, app.name)) {
	@Override
	protected IStatus run(IProgressMonitor monitor) {
		try {
			for (ProjectLogInfo logInfo : app.getLogInfos()) {
				SocketConsole console = app.getConsole(logInfo);
				if (console != null) {
					IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
					consoleManager.removeConsoles(new IConsole[] { console });
					app.removeConsole(console);
				}
			}
			return Status.OK_STATUS;
		} catch (Exception e) {
			Logger.logError("An error occurred closing the log files for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
			return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.HideAllLogFilesError, app.name), e);
		}
	}
};
job.schedule();
  }
 
Example #28
Source File: EnableDisableProjectAction.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void enableDisableProject(CodewindApplication app, boolean enable) {
	Job job = new Job(NLS.bind(Messages.EnableDisableProjectJob, app.name)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				app.connection.requestProjectOpenClose(app, enable);
				return Status.OK_STATUS;
			} catch (Exception e) {
				Logger.logError("An error occurred updating enablement for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
				return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnEnableDisableProject, app.name), e);
			}
		}
	};
	job.schedule();
}
 
Example #29
Source File: SvnUtil.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * This method returns dialog message for missing files.
 * 
 * @param joinedMissingFiles
 *            all the file names joined.
 * @param workingFolderManual
 *            path of the working folder.
 * @param mergeUnit
 *            {link SVNMergeUnit} .
 * @return dialog message string.
 */
private static String getDialogScrollableMessage(String joinedMissingFiles, String workingFolderManual,
		SVNMergeUnit mergeUnit) {
	String messageIntro = NLS.bind(Messages.SvnUtilSvnkit_MovedFiles_Intro, joinedMissingFiles);
	String commandCreateFolder = String.format("MD %s%n", workingFolderManual); //$NON-NLS-1$
	String commandChangeFolder = String.format("CD %s%n", workingFolderManual); //$NON-NLS-1$
	String commandCheckout = String.format("SVN checkout %s <PATH_OF_MOVED_FILE_IN_TARGET_BRANCH>%n", //$NON-NLS-1$
			mergeUnit.getUrlTarget());
	String commandMerge = String.format(
			"SVN merge -r %d:%d %s <PATH_OF_MOVED_FILE_IN_SOURCE_BRANCH> <FILENAME> --accept postpone %n", //$NON-NLS-1$
			mergeUnit.getRevisionStart(), mergeUnit.getRevisionEnd(), mergeUnit.getUrlSource());
	String commandCommit = String.format("SVN commit -m \"Manual Merge: [%d:%d] %s -> %s\" %s%n", //$NON-NLS-1$
			mergeUnit.getRevisionStart(), mergeUnit.getRevisionEnd(), getBranchName(mergeUnit.getUrlSource()),
			getBranchName(mergeUnit.getUrlTarget()), workingFolderManual);
	String commandRemoveFolder = String.format("RD /S /Q %s%n", workingFolderManual); //$NON-NLS-1$

	StringBuilder sb = new StringBuilder();
	sb.append(messageIntro);
	sb.append(commandCreateFolder);
	sb.append(commandChangeFolder);
	sb.append(commandCheckout);
	sb.append(commandMerge);
	sb.append(commandCommit);
	sb.append(commandRemoveFolder);

	return sb.toString();
}
 
Example #30
Source File: SVNMergeUtil.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
public static boolean copyLocalToDone(SVNMergeUnit mergeUnit) {
	LogUtil.entering(mergeUnit);

	boolean cancel = false;
	while (!cancel) {
		try {
			SftpUtil.getInstance().copyMergeUnitFromWorkToDoneAndDeleteInTodo(mergeUnit);
			mergeUnit.setStatus(MergeUnitStatus.DONE);
			break;
		} catch (SftpUtilException e) {
			String logMessage = String.format("Caught exception while copying from work to done. mergeUnit=[%s]", //$NON-NLS-1$
					mergeUnit);
			LOGGER.log(Level.WARNING, logMessage, e);

			String message = NLS.bind(Messages.MergeProcessorUtil_CopyLocalToDone_Error_Message, Choices.CANCEL,
					MergeUnitStatus.TODO);
			String messageScrollable = NLS.bind(Messages.MergeProcessorUtil_CopyLocalToDone_Error_Details,
					e.getMessage());
			if (MergeProcessorUtil.bugUserToFixProblem(message, messageScrollable)) {
				// user wants to retry
				LOGGER.fine(String.format("User wants to retry copying the merge file to the server. mergeUnit=%s.", //$NON-NLS-1$
						mergeUnit));
				continue;
			} else {
				// user didn't say 'retry' so we cancel the whole merge...
				LOGGER.fine(String.format("User cancelled committing changes from the working copy. mergeUnit=%s.", //$NON-NLS-1$
						mergeUnit));
				cancel = true;
			}
		}
	}

	return LogUtil.exiting(cancel);
}