Skip to content

Commit

Permalink
Merge pull request #443 from bsinno/development
Browse files Browse the repository at this point in the history
Fix for #440
  • Loading branch information
aedelmann authored Nov 24, 2016
2 parents 4a43580 + cad9d8f commit 323889e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bundles/org.eclipse.vorto.core.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.resources,
org.apache.commons.collections,
org.eclipse.vorto.core,
org.eclipse.ui.console,
org.eclipse.text
org.eclipse.text,
org.eclipse.ui.workbench
Export-Package: org.eclipse.vorto.core.ui,org.eclipse.vorto.core.ui.ex
ception,org.eclipse.vorto.core.ui.model,org.eclipse.vorto.core.ui.mod
el.nature,org.eclipse.vorto.core.ui.parser;uses:="org.eclipse.core.re
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected static enum MSG_KIND {
private static Color errorColor;
private static Color successColor;
private static final String SEPERATOR = "------------------------------------------------------------------------";

private DefaultMessageDisplay(String messageTitle) {
// fDefault = this;
fTitle = messageTitle;
Expand Down Expand Up @@ -90,7 +91,9 @@ protected void println(final String msg, final MSG_KIND msgKind) {
public void run() {
if (msg == null)
return;
if (!displayConsoleView()) {

IViewPart consoleViewPart = displayConsoleView();
if (consoleViewPart == null) {
MessageDialog.openError(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), "Error",
msg);
Expand Down Expand Up @@ -118,6 +121,11 @@ public void run() {
try {
getNewMessageConsoleStream(msgKind).write(msgWithMarker);
getNewMessageConsoleStream(msgKind).write('\n');

if (msgKind == MSG_KIND.ERROR) {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(consoleViewPart);
}

} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -192,23 +200,24 @@ public void displayNewLine() {
println(SEPERATOR, MSG_KIND.INFO);
}

private boolean displayConsoleView() {
public IViewPart displayConsoleView() {
try {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
IWorkbenchPage activePage = activeWorkbenchWindow
.getActivePage();
if (activePage != null)
activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW,
if (activePage != null) {
return activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW,
null, IWorkbenchPage.VIEW_VISIBLE);
}
}

} catch (PartInitException partEx) {
return false;
throw new RuntimeException("Cannot open console view");
}

return true;
return null;
}

public IOConsoleOutputStream getNewMessageConsoleStream(MSG_KIND msgKind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface IMessageDisplay {
* Insert a line break in the display
*/
void displayNewLine();

/**
* Clear current display
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public IModelElement performDrop(IModelProject receivingModelElement, ModelResou
Objects.requireNonNull(receivingModelElement, "receivingModelElement shouldn't be null.");
Objects.requireNonNull(modelResource, "droppedObject shouldn't be null.");


return downloadAndSaveModel(receivingModelElement, modelResource.getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.eclipse.vorto.core.api.model.model.ModelType;
import org.eclipse.vorto.core.api.repository.ModelResource;
import org.eclipse.vorto.core.ui.MessageDisplayFactory;
import org.eclipse.vorto.perspective.dnd.IDropValidator;

/**
Expand All @@ -37,8 +38,12 @@ public boolean allow(Object receivingModelElement, Object droppedObject) {
if (droppedObject instanceof ModelResource && targetClass.isInstance(receivingModelElement)) {
ModelResource model = (ModelResource) droppedObject;
return model.getId().getModelType() == modelType;
} else {
if (!targetClass.isInstance(receivingModelElement)) {
MessageDisplayFactory.getMessageDisplay().displayError("Please create a Project first before dropping models from the repository.");
}
return false;
}
return false;
}

}

0 comments on commit 323889e

Please sign in to comment.