Exemple #1
0
 /**
  * Returns the local current directory path set up by the user
  *
  * <p>This is where local files are stored; e.g. when retrieving a file from the remote server,
  * it'll be stored there.
  *
  * @param isSaveLocallyOn: true => files retrieved from server are saved locally in a user
  *     designated directory, this is the one returned. false => a hardcoded directory, for
  *     temporary operations, is returned.
  * @return String - local workspace directory. e.g.
  *     "C\:eclipse\workspace\Basic_project\subdirectory" If no directory has yet been specified
  *     it'll return "".
  */
 public static String getLocalCurDirectory(boolean isSaveLocallyOn) {
   if (isSaveLocallyOn) {
     IPreferenceStore store = (IPreferenceStore) T24BasicPlugin.getBean("preferenceStore");
     String localDir = store.getString(PluginConstants.T24_LOCAL_DIRECTORY);
     return localDir;
   } else {
     /**
      * basicFiles are not saved locally when retrieved from server, so they are temporarily placed
      * in a pre-defined temporary project. They'll be deleted from there at some point (e.g. when
      * their editor closes) .
      */
     return getTemporaryProject().toOSString();
   }
 }
 /**
  * Needed for content assistant in the Text viewer. This ensures actions such as key press would
  * trigger content assistant
  */
 @SuppressWarnings("deprecation")
 protected void createActions() {
   super.createActions();
   ResourceBundle bundle = T24BasicPlugin.getDefault().getResourceBundle();
   String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
   Action action = new ContentAssistAction(bundle, "ContentAssistProposal", this);
   action.setActionDefinitionId(id);
   setAction("ContentAssistProposal", action);
   this.markAsContentDependentAction(id, true);
   ResourceAction printAction =
       new TextOperationAction(bundle, "Editor.Print.", this, ITextOperationTarget.PRINT, true);
   String printid = IWorkbenchActionDefinitionIds.PRINT;
   printAction.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
   printAction.setActionDefinitionId(printid);
   setAction(ITextEditorActionConstants.PRINT, new PrintActionDecorator(printAction));
   this.markAsContentDependentAction(printid, true);
 }
/** Colors preference page. */
public class T24BasicPreferenceColorPage extends PreferencePage
    implements IWorkbenchPreferencePage {
  public static final String PREFERENCES_PAGE_ID =
      "t24.tools.eclipse.T24BasicPreferences.EditorColors";
  public static final String COLOR_PREFERENCE_PAGE_TITLE = "T24 Basic Editor Colors";

  private static IPreferenceStore store =
      (IPreferenceStore) T24BasicPlugin.getBean("preferenceStore");
  private ColorFieldEditor backgroundColorField;
  private ColorFieldEditor commentColorField;
  private ColorFieldEditor commonVariableColorField;
  private ColorFieldEditor defaultColorField;
  private ColorFieldEditor keywordColorField;
  private ColorFieldEditor literalColorField;
  private ColorFieldEditor hyperlinkColorField;

  public T24BasicPreferenceColorPage() {
    super();
  }

  /** {@inheritDoc} */
  public void init(IWorkbench workbench) {
    // initialise the preference store we wish to use
    setPreferenceStore(store);
  }

  /*
   * @see PreferencePage#createContents(Composite)
   */
  @Override
  protected Control createContents(Composite parent) {

    Composite topComposite = new Composite(parent, SWT.NULL);
    // Sets the layout for the composite's children to populate.
    topComposite.setLayout(new GridLayout());
    // Sets the layout data for the top composite's place in its parent's layout.
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    topComposite.setLayoutData(data);

    Group colorGroup = new Group(topComposite, SWT.NONE);
    colorGroup.setText("Basic editor colors");
    colorGroup.setLayout(new GridLayout());
    GridData colorData = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = false;
    colorGroup.setLayoutData(colorData);

    // ***************************************************************************
    //                          COLORS
    // ***************************************************************************
    commentColorField =
        new ColorFieldEditor(PluginConstants.T24_EDITOR_COLOR_COMMENT, "C&omment", colorGroup);
    commentColorField.setPreferenceStore(store);
    RGB rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_COMMENT);
    PreferenceConverter.setValue(store, commentColorField.getPreferenceName(), rgb);
    commentColorField.load();

    backgroundColorField =
        new ColorFieldEditor(
            PluginConstants.T24_EDITOR_COLOR_BACKGROUND, "B&ackground", colorGroup);
    backgroundColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_BACKGROUND);
    PreferenceConverter.setValue(store, backgroundColorField.getPreferenceName(), rgb);
    backgroundColorField.load();

    commonVariableColorField =
        new ColorFieldEditor(
            PluginConstants.T24_EDITOR_COLOR_COMMON_VARIABLE, "Common V&ar", colorGroup);
    commonVariableColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_COMMON_VARIABLE);
    PreferenceConverter.setValue(store, commonVariableColorField.getPreferenceName(), rgb);
    commonVariableColorField.load();

    defaultColorField =
        new ColorFieldEditor(PluginConstants.T24_EDITOR_COLOR_DEFAULT, "C&ode", colorGroup);
    defaultColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_DEFAULT);
    PreferenceConverter.setValue(store, defaultColorField.getPreferenceName(), rgb);
    defaultColorField.load();

    keywordColorField =
        new ColorFieldEditor(PluginConstants.T24_EDITOR_COLOR_KEYWORD, "K&eyword", colorGroup);
    keywordColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_KEYWORD);
    PreferenceConverter.setValue(store, keywordColorField.getPreferenceName(), rgb);
    keywordColorField.load();

    literalColorField =
        new ColorFieldEditor(PluginConstants.T24_EDITOR_COLOR_LITERAL, "L&iteral", colorGroup);
    literalColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_LITERAL);
    PreferenceConverter.setValue(store, literalColorField.getPreferenceName(), rgb);
    literalColorField.load();

    hyperlinkColorField =
        new ColorFieldEditor(PluginConstants.T24_EDITOR_COLOR_HYPERLINK, "H&yperlink", colorGroup);
    hyperlinkColorField.setPreferenceStore(store);
    rgb = PreferenceConverter.getColor(store, PluginConstants.T24_EDITOR_COLOR_HYPERLINK);
    PreferenceConverter.setValue(store, hyperlinkColorField.getPreferenceName(), rgb);
    hyperlinkColorField.load();

    return topComposite;
  }

  /** {@inheritDoc} */
  @Override
  public boolean performOk() {

    if (isControlCreated()) {
      RGB rgb = backgroundColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_BACKGROUND, rgb);

      rgb = commentColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_COMMENT, rgb);

      rgb = commonVariableColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_COMMON_VARIABLE, rgb);

      rgb = defaultColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_DEFAULT, rgb);

      rgb = keywordColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_KEYWORD, rgb);

      rgb = literalColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_LITERAL, rgb);

      rgb = hyperlinkColorField.getColorSelector().getColorValue();
      PreferenceConverter.setValue(store, PluginConstants.T24_EDITOR_COLOR_HYPERLINK, rgb);
    }
    return super.performOk();
  }

  /** {@inheritDoc} */
  @Override
  protected void performDefaults() {
    super.performDefaults();

    if (isControlCreated()) {
      backgroundColorField.loadDefault();
      commentColorField.loadDefault();
      commonVariableColorField.loadDefault();
      defaultColorField.loadDefault();
      keywordColorField.loadDefault();
      literalColorField.loadDefault();
      hyperlinkColorField.loadDefault();
    }
  }
}
Exemple #4
0
 /**
  * Returns the IPath pointing to where the plugin stores its state.
  *
  * @return
  */
 public static IPath getPluginStateLocation() {
   T24BasicPlugin plugin = T24BasicPlugin.getDefault();
   IPath stateLocation = plugin.getStateLocation();
   return stateLocation;
 }
Exemple #5
0
 /**
  * Returns the current preference store
  *
  * @return IPreferenceStore current preference store
  */
 public static IPreferenceStore getPreferenceStore() {
   return (IPreferenceStore) T24BasicPlugin.getBean("preferenceStore");
 }
Exemple #6
0
 public static boolean isSaveLocallyOn() {
   IPreferenceStore store = (IPreferenceStore) T24BasicPlugin.getBean("preferenceStore");
   boolean saveLocallyOn = store.getBoolean(PluginConstants.T24_SAVE_LOCALLY_BY_DEFAULT_ON);
   return saveLocallyOn;
 }
Exemple #7
0
 /**
  * @return local default project (as set in preferences) (e.g. C\:eclipse\workspace\Basic_project)
  */
 public static String getLocalDefaultProject() {
   IPreferenceStore store = (IPreferenceStore) T24BasicPlugin.getBean("preferenceStore");
   String localDefaultProject =
       store.getString(PluginConstants.T24_LOCAL_DEFAULT_PROJECT_FULLPATH);
   return localDefaultProject;
 }