Skip to content

Commit

Permalink
quick fixes, adjusted action sets, logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
amlajmi committed Feb 12, 2017
1 parent b176a06 commit 2c50460
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Require-Bundle: org.eclipse.rap.ui,
org.dslforge.xtext.common,
org.dslforge.texteditor,
org.dslforge.styledtext,
org.codingpark.piraterobot.play
org.codingpark.piraterobot.play,
org.eclipse.rap.ui.forms,
org.codingpark.piraterobot.widget
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.codingpark.piraterobot.play.web.contentassist,
org.codingpark.piraterobot.play.web.editor,
org.codingpark.piraterobot.play.web.editor.widget,
org.codingpark.piraterobot.play.web.module
3 changes: 2 additions & 1 deletion plugins/org.dslforge.styledtext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.dslforge.styledtext,
org.dslforge.styledtext.jface
Bundle-ClassPath: .
Import-Package: org.apache.log4j
Import-Package: org.apache.log4j,
org.eclipse.ui.forms.widgets
Original file line number Diff line number Diff line change
Expand Up @@ -17,76 +17,60 @@

public class TextViewer extends Viewer implements ITextViewer{

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = -5997421207828153511L;

private BasicText fTextWidget;
private IDocument fDocument;
private Control fDisposedControl;

protected TextViewer() {
super();
}


/**
* Create a new text viewer with the given SWT style bits.
*
* @param parent the parent of the viewer's control
* @param styles the SWT style bits for the viewer's control
* Create a new text viewer with the given style bits.
*/
public TextViewer(Composite parent, int styles) {
createControl(parent, styles);
}

/**
* Create a new text viewer based on the text widget given as input
*
* @param textWidget the available text widget
* Create a new text viewer with the given style bits.
*/
public TextViewer(BasicText textWidget) {
public TextViewer(BasicText textWidget, Composite parent, int styles) {
fTextWidget = textWidget;
configureTextWidget(textWidget.getParent());
configure();
}

/**
* Creates the viewer's SWT control. The viewer's text widget either is
* Creates the viewer's control. The viewer's text widget either is
* the control or is a child of the control.
*
* @param parent the parent of the viewer's control
* @param styles the SWT style bits for the viewer's control
*/
protected void createControl(Composite parent, int styles) {
fTextWidget= createTextWidget(parent, styles);
configureTextWidget(parent);
fTextWidget = createTextWidget(parent, styles);
configure();
}

/**
* Configures the editor's text widget
*/
@SuppressWarnings("serial")
private void configureTextWidget(Composite parent) {
private void configure() {
GridData textLayoutData = new GridData();
textLayoutData.horizontalAlignment = SWT.FILL;
textLayoutData.verticalAlignment = SWT.FILL;
textLayoutData.grabExcessHorizontalSpace = true;
textLayoutData.grabExcessVerticalSpace = true;
fTextWidget.setLayoutData(textLayoutData);

fTextWidget.addDisposeListener(
new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
fDisposedControl= getControl();
handleDispose();
}
}
);

fTextWidget.setFont(parent.getFont());

fTextWidget.addTraverseListener(new TraverseListener() {
private static final long serialVersionUID = 1L;

public void keyTraversed(TraverseEvent e) {
if ((SWT.SHIFT == e.stateMask) && ('\t' == e.character))
e.doit= !fTextWidget.getEditable();
}
});
fTextWidget.addDisposeListener(new DisposeListener() {
private static final long serialVersionUID = 1L;

public void widgetDisposed(DisposeEvent e) {
fDisposedControl = getControl();
handleDispose();
}
});
}

/**
Expand All @@ -97,28 +81,16 @@ public void keyTraversed(TraverseEvent e) {
* @return the text widget to be used
*/
protected BasicText createTextWidget(Composite parent, int styles) {
BasicText textWidget= new BasicText(parent, styles);
return textWidget;
BasicText styledText= new BasicText(parent, styles);
return styledText;
}

/**
* @see Viewer#getControl()
*/

@Override
public Control getControl() {
return fTextWidget != null ? fTextWidget : fDisposedControl;
}

/**
* Frees all resources allocated by this viewer. Internally called when the viewer's
* control has been disposed.
*/
protected void handleDispose() {
fTextWidget= null;
}

/**
* @see Viewer#getInput()
*/
@Override
public Object getInput() {
return getDocument();
}
Expand Down Expand Up @@ -168,25 +140,19 @@ public void setText(String text) {
fDocument.set(text);
}

/**
* @see ITextViewer#getDocument()
*/
@Override
public IDocument getDocument() {
return fDocument;
}

/**
* @see ITextViewer#isEditable()
*/
@Override
public boolean isEditable() {
if (fTextWidget == null)
return false;
return fTextWidget.getEditable();
}

/**
* @see ITextViewer#setEditable(boolean)
*/
@Override
public void setEditable(boolean editable) {
if (fTextWidget != null)
fTextWidget.setEditable(editable);
Expand All @@ -202,4 +168,11 @@ public void setSelection(ISelection selection, boolean reveal) {
if (reveal)
setSelection(selection);
}

/**
* Frees all resources allocated by this viewer.
*/
protected void handleDispose() {
fTextWidget= null;
}
}
2 changes: 2 additions & 0 deletions plugins/org.dslforge.texteditor/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ Bundle-Version: 0.9.1.qualifier
Bundle-Activator: org.dslforge.texteditor.internal.Activator
Require-Bundle: org.eclipse.rap.ui,
org.eclipse.rap.ui.views,
org.eclipse.rap.ui.forms,
org.eclipse.emf.common,
org.eclipse.emf.rap.common.ui,
org.dslforge.styledtext
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.dslforge.texteditor,
org.dslforge.texteditor.actions,
org.dslforge.texteditor.form,
org.dslforge.texteditor.internal
Bundle-Vendor: PlugBee
Import-Package: org.apache.log4j
20 changes: 1 addition & 19 deletions plugins/org.dslforge.texteditor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,15 @@
parentId="org.eclipse.ui.textEditorScope">
</context>
</extension>
<!-- @generated dslforge -->
<extension point="org.eclipse.ui.editors">
<editor
class="org.dslforge.texteditor.BasicTextEditor"
contributorClass="org.dslforge.texteditor.BasicTextEditorContributor"
default="false"
extensions="txt"
icon="icons/file_obj.png"
id="org.dslforge.xtext.common.web.editor"
id="org.dslforge.texteditor.default"
name="Text Editor">
</editor>
</extension>
<!--
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="org.dslforge.xtext.common.compiler.java.contribution"
nameFilter="*.java"
objectClass="java.io.File">
<action
class="org.dslforge.xtext.common.compiler.DynamicCompiler"
icon="icons/run_exec.png"
id="org.dslforge.xtext.common.compiler.java.action"
label="Run">
</action>
</objectContribution>
</extension>
-->
</plugin>
80 changes: 62 additions & 18 deletions plugins/org.dslforge.workspace.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@
id="org.dslforge.workspace.ui.commands.NewProject"
name="CreateNewProject">
</command>
<command
defaultHandler="org.dslforge.workspace.ui.commands.OpenResourceCommand"
description="Open file"
helpContextId="Open file"
id="org.dslforge.workspace.ui.commands.OpenResource"
name="OpenResource">
</command>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
Expand Down Expand Up @@ -108,8 +115,8 @@
label="Folder"
menubarPath="org.dslforge.workspace.menu.new/group1"
style="push"
tooltip="Create a new folder">
</action>
tooltip="Open with default editor">
</action>
<menu
id="org.dslforge.workspace.menu.new"
label="New"
Expand All @@ -126,35 +133,51 @@
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="org.dslforge.navigator.view.actions.contribution.delete"
id="org.dslforge.navigator.view.actions.contribution.open"
nameFilter="*"
objectClass="java.io.File">
<action
class="org.dslforge.workspace.ui.actions.DeleteResourceAction"
class="org.dslforge.workspace.ui.actions.OpenResourceAction"
enablesFor="*"
icon="icons/delete.png"
id="org.dslforge.workspace.menu.delete"
label="Delete"
id="org.dslforge.workspace.menu.open"
label="Open"
menubarPath="main"
style="push">
</action>
</objectContribution>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="org.dslforge.navigator.view.actions.contribution.open"
id="org.dslforge.navigator.view.actions.contribution.openwith"
nameFilter="*"
objectClass="java.io.File">
<action
class="org.dslforge.workspace.ui.actions.OpenResourceAction"
enablesFor="*"
id="org.dslforge.workspace.menu.open"
label="Open"
menubarPath="main"
style="push">
icon="icons/file.gif"
id="org.dslforge.workspace.menu.openwith.default"
label="Text Editor (default)"
menubarPath="org.dslforge.workspace.menu.openwith/additions"
style="push"
tooltip="Open with default editor">
</action>
<action
class="org.dslforge.workspace.ui.actions.OpenResourceInFormAction"
enablesFor="*"
icon="icons/model.png"
id="org.dslforge.workspace.menu.openwith.form"
label="Form Editor"
menubarPath="org.dslforge.workspace.menu.openwith/additions"
style="push"
tooltip="Open with form editor">
</action>
<menu
id="org.dslforge.workspace.menu.openwith"
label="Open With"
path="main">
<separator
name="group2">
</separator>
</menu>
</objectContribution>
</extension>
<extension
Expand Down Expand Up @@ -182,6 +205,24 @@
</menu>
</viewerContribution>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="org.dslforge.navigator.view.actions.contribution.delete"
nameFilter="*"
objectClass="java.io.File">
<action
class="org.dslforge.workspace.ui.actions.DeleteResourceAction"
enablesFor="*"
icon="icons/delete.png"
id="org.dslforge.workspace.menu.delete"
label="Delete"
menubarPath="group1"
style="push">
</action>
</objectContribution>
</extension>

<extension
point="org.eclipse.ui.actionSets">
Expand All @@ -194,7 +235,8 @@
definitionId="org.dslforge.workspace.ui.commands.newFile"
icon="icons/file_obj.gif"
id="org.dslforge.workspace.ui.actions.newFile"
label="New File"
label="File"
menubarPath="file/new/additions"
retarget="false"
style="push"
toolbarPath="main"
Expand All @@ -205,7 +247,8 @@
definitionId="org.dslforge.workspace.ui.commands.newFolder"
icon="icons/fldr_obj.png"
id="org.dslforge.workspace.ui.actions.newFolder"
label="New Folder"
label="Folder"
menubarPath="file/new/additions"
retarget="false"
style="push"
toolbarPath="main"
Expand All @@ -216,7 +259,8 @@
definitionId="org.dslforge.workspace.ui.commands.NewProject"
icon="icons/prj_obj.png"
id="org.dslforge.workspace.ui.actions.newProject"
label="New Project"
label="Project"
menubarPath="file/new/additions"
retarget="false"
style="push"
toolbarPath="main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public void run(IAction action) {
wizardDialog.open();
}
}

}
}
Loading

0 comments on commit 2c50460

Please sign in to comment.