Skip to content

Commit

Permalink
Evolve the API
Browse files Browse the repository at this point in the history
- Create new interface (ITerminalListener3) so clients can opt in to
  new API but clients that haven't updated will still work
  as they are called from VT100TerminalControl.setTerminalTitle
- Restore the ITerminalControl.setTerminalTitle(String) and
  ITerminalViewControl.setTerminalTitle(String)
- Mark all the old methods as deprecated for removal and document
  plan to remove
- Fix and update all version numbers (since tags, MANIFEST versions
  and dependencies ranges)
  • Loading branch information
jonahgraham committed Aug 16, 2023
1 parent c6841a7 commit 18634bb
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 14 deletions.
12 changes: 12 additions & 0 deletions NewAndNoteworthy/CHANGELOG-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,15 @@ spelled BuiltinDetectionArgsGeneric instead.
These APIs will be removed and remote connection for attach launch will be moved in the implementation of `IGDBProcesses.attachDebuggerToProcess()`.

See https://github.com/eclipse-cdt/cdt/pull/336

## API Removals after September 2025

### Terminal Control API for setting title without `requestor` will be removed

These APIs will be removed and are replaced by versions with `requestor` parameter.

- org.eclipse.tm.internal.terminal.control.ITerminalListener.setTerminalTitle(String)
- org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl.setTerminalTitle(String)
- org.eclipse.tm.internal.terminal.control.ITerminalViewControl.setTerminalTitle(String)

See https://github.com/eclipse-cdt/cdt/issues/494
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.connector.remote;singleton:=true
Bundle-Version: 4.8.0.qualifier
Bundle-Version: 4.8.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
Expand All @@ -13,8 +13,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.swt,
org.eclipse.jface,
org.eclipse.tm.terminal.view.core;bundle-version="4.5.0";resolution:=optional,
org.eclipse.tm.terminal.view.ui;bundle-version="4.5.0";resolution:=optional,
org.eclipse.tm.terminal.view.core;bundle-version="4.10.0";resolution:=optional,
org.eclipse.tm.terminal.view.ui;bundle-version="4.11.100";resolution:=optional,
org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: org.eclipse.tm.terminal.connector.remote,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.control; singleton:=true
Bundle-Version: 5.4.100.qualifier
Bundle-Version: 5.5.0.qualifier
Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public interface ITerminalListener {
void setState(TerminalState state);

/**
* Set the title of the terminal.
* @deprecated Migrate to implementing {@link ITerminalListener3} and
* override {@link ITerminalListener3#setTerminalTitle(String, String)
* @param title
* @param requestor Who requests update.
*/
void setTerminalTitle(String title, String requestor);
@Deprecated(forRemoval = true)
void setTerminalTitle(String title);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2023 YOUR COPYRIGHT HOLDER HERE
*
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License 2.0 which accompanies this distribution, and is
* available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tm.internal.terminal.control;

/**
* TODO add comment here to say that if ITerminalListener3 is implemented,
* {@link #setTerminalTitle(String, String)} will be called instead of {@link #setTerminalTitle(String)}
*
* @since 5.5
*/
public interface ITerminalListener3 extends ITerminalListener2 {

/**
* Set the title of the terminal.
*
* @param title
* @param requestor Who requests update.
*/
void setTerminalTitle(String title, String requestor);
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,17 @@ public interface ITerminalViewControl {
*/
void removeMouseListener(ITerminalMouseListener listener);

/**
* @deprecated call {@link #setTerminalTitle(String, String)} instead
*/
@Deprecated(forRemoval = true)
void setTerminalTitle(String newTitle);

/**
* Set the title of the terminal.
* @param newTitle
* @param requestor Who requests update.
* @since 5.5
*/
void setTerminalTitle(String newTitle, String requestor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import org.eclipse.tm.internal.terminal.control.ICommandInputField;
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
import org.eclipse.tm.internal.terminal.control.ITerminalListener2;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3;
import org.eclipse.tm.internal.terminal.control.ITerminalMouseListener;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText;
Expand Down Expand Up @@ -1259,9 +1260,20 @@ private void processKeyBinding(KeyEvent event, int accelerator) {

}

@Override
public void setTerminalTitle(String title) {
setTerminalTitle(title,
"deprecated or unknown or null (depending on what the enum that replaces this string looks like)");
}

@Override
public void setTerminalTitle(String title, String requestor) {
fTerminalListener.setTerminalTitle(title, requestor);
if (fTerminalListener instanceof ITerminalListener3 listener3) {
listener3.setTerminalTitle(title, requestor);
} else {
fTerminalListener.setTerminalTitle(title);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,17 @@ public interface ITerminalControl {
*/
OutputStream getRemoteToTerminalOutputStream();

/**
* @deprecated call {@link #setTerminalTitle(String, String)} instead
*/
@Deprecated(forRemoval = true)
void setTerminalTitle(String title);

/**
* Set the title of the terminal view.
* @param title
* @param requestor Who requests title update.
* @since 5.5
*/
void setTerminalTitle(String title, String requestor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public void setMsg(String msg) {
public void setState(TerminalState state) {
}

@Override
public void setTerminalTitle(String title) {
}

@Override
public void setTerminalTitle(String title, String requestor) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public void setMsg(String msg) {
public void setState(TerminalState state) {
}

@Override
public void setTerminalTitle(String title) {
}

@Override
public void setTerminalTitle(String title, String requestor) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.view.core;singleton:=true
Bundle-Version: 4.9.100.qualifier
Bundle-Version: 4.10.0.qualifier
Bundle-Activator: org.eclipse.tm.terminal.view.core.activator.CoreBundleActivator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public interface ITerminalsConnectorConstants {
* using terminal API and ANSI command.
* <p>
* Property Type: {@link String}
* @since 4.10
*/
public static final String PROP_TITLE_UPDATE_API = "titleUpdateAPI"; //$NON-NLS-1$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400",
org.eclipse.core.variables;bundle-version="3.2.600",
org.eclipse.debug.ui;bundle-version="3.8.1";resolution:=optional,
org.eclipse.egit.ui;bundle-version="2.0.0";resolution:=optional,
org.eclipse.tm.terminal.view.core;bundle-version="[4.8.0,5.0.0)",
org.eclipse.tm.terminal.control;bundle-version="[5.2.0,6.0.0)",
org.eclipse.tm.terminal.view.core;bundle-version="[4.10.0,5.0.0)",
org.eclipse.tm.terminal.control;bundle-version="[5.5.0,6.0.0)",
org.eclipse.ui;bundle-version="3.8.0",
org.eclipse.ui.ide;bundle-version="3.18.0";resolution:=optional,
org.eclipse.ui.editors;bundle-version="3.14.0";resolution:=optional,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tm.internal.terminal.control.ITerminalListener2;
import org.eclipse.tm.internal.terminal.control.ITerminalListener3;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
import org.eclipse.tm.terminal.view.core.interfaces.constants.ITerminalsConnectorConstants;
import org.eclipse.tm.terminal.view.ui.nls.Messages;

/**
* Terminal tab default terminal listener implementation.
*/
public class TabTerminalListener implements ITerminalListener2 {
public class TabTerminalListener implements ITerminalListener3 {
private static final String TAB_TERMINAL_LISTENER = "TabTerminalListener"; //$NON-NLS-1$
/* default */ final TabFolderManager tabFolderManager;
private CTabItem tabItem;
Expand Down Expand Up @@ -163,14 +163,19 @@ protected String getTerminalConsoleTabTitle(TerminalState state) {
return newTitle != null && !newTitle.equals(oldTitle) ? newTitle : null;
}

@Override
public void setTerminalTitle(String title) {
throw new UnsupportedOperationException("Should not be called as this class implements ITerminalListener3"); //$NON-NLS-1$
}

/**
* Sets Terminal tilte and checks if originator is ANSI command.
* If originator is ANSI command in terminal and user does not want to use
* ANSI command to upate terminal then return else update title.
* @param title Title to update.
* @param requestor Who requests title update. Can be null.
* @since 11.3
*/
@Override
public void setTerminalTitle(String title, String requestor) {

CTabItem item = getTabItem();
Expand Down

0 comments on commit 18634bb

Please sign in to comment.